Unix administration - what's teh simplest way to run a command periodically?

This is Interesting: Free IT Magazines  
Home > Archive > Unix administration > January 2004 > what's teh simplest way to run a command periodically?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author what's teh simplest way to run a command periodically?
walala

2004-01-23, 5:07 pm

Dear all,

How can I setup my unix host to run "kill_spam.pl" 8 times a day?

I am remotely login onto a workstation "workstation.mydomain.edu", and want
to configure that workstation to run "perl kill_spam.pl" 8 times a day to
kill those spam emails... I have already designed and tested kill_spam.pl
and want it to run periodically...

How to do that? And what is the simplest way to do that?

-Walalal


Davide Bianchi

2004-01-23, 5:07 pm

walala <mizhael@yahoo.com> wrote:
quote:

> How can I setup my unix host to run "kill_spam.pl" 8 times a day?



Use cron.
man cron
man crontab

for more information

Davide
Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

walala <mizhael@yahoo.com> wrote ...
quote:

> How can I setup my unix host to run "kill_spam.pl" 8 times a day?
>
> I am remotely login onto a workstation "workstation.mydomain.edu", and want
> to configure that workstation to run "perl kill_spam.pl" 8 times a day to
> kill those spam emails... I have already designed and tested kill_spam.pl
> and want it to run periodically...
>
> How to do that? And what is the simplest way to do that?



man (1) crontab

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6U32miD+5zjSqyTEQKKvACfWI9eFrzSG2SW
yyLRkC1BJGZ9m7sAoKMG
OwQm8bsxIkR0jr0LMOcpXWT6
=v/yV
-----END PGP SIGNATURE-----
Chris F.A. Johnson

2004-01-23, 5:07 pm

On Sun, 02 Nov 2003 at 17:45 GMT, walala wrote:
quote:

> Dear all,
>
> How can I setup my unix host to run "kill_spam.pl" 8 times a day?
>
> I am remotely login onto a workstation "workstation.mydomain.edu", and want
> to configure that workstation to run "perl kill_spam.pl" 8 times a day to
> kill those spam emails... I have already designed and tested kill_spam.pl
> and want it to run periodically...
>
> How to do that? And what is the simplest way to do that?



Put it in a cron job. The method is described in the man pages for
cron and crontab:

man cron
man crontab
man 5 crontab

--
Chris F.A. Johnson http://cfaj.freeshell.org
========================================
===========================
My code (if any) in this post is copyright 2003, Chris F.A. Johnson
and may be copied under the terms of the GNU General Public License
walala

2004-01-23, 5:07 pm


"Chris F.A. Johnson" <c.fa.johnson@rogers.com> wrote in message
news:bo3o2h$17a32h$2@ID-210011.news.uni-berlin.de...
quote:

> On Sun, 02 Nov 2003 at 17:45 GMT, walala wrote:
want[QUOTE][color=darkred]
to[QUOTE][color=darkred]
kill_spam.pl[QUOTE][color=darkred]
>
> Put it in a cron job. The method is described in the man pages for
> cron and crontab:
>
> man cron
> man crontab
> man 5 crontab
>
> --
> Chris F.A. Johnson http://cfaj.freeshell.org
> ========================================
===========================
> My code (if any) in this post is copyright 2003, Chris F.A. Johnson
> and may be copied under the terms of the GNU General Public License



Dear all,

Thank you all for your answers. I made it! Now it filters my spam email very
one hour... :=)

Yet one more question: is the "crontab" command disconnection-proof?

What if I disconnect my terminal and logout?

Thanks,

-Walala


Tim Slattery

2004-01-23, 5:07 pm

"walala" <mizhael@yahoo.com> wrote:
quote:

>Yet one more question: is the "crontab" command disconnection-proof?
>
>What if I disconnect my terminal and logout?



"Cron" is a daemon that runs all the time in your Unix box. The job
you specified in your crontab entry will run at the times you set
whether you - or anybody else - is logged in or not.

--
Tim Slattery
Slattery_T@bls.gov
Jaime Cardoso

2004-01-23, 5:07 pm

quote:

> Dear all,
>
> Thank you all for your answers. I made it! Now it filters my spam email very
> one hour... :=)
>
> Yet one more question: is the "crontab" command disconnection-proof?
>
> What if I disconnect my terminal and logout?
>
> Thanks,
>
> -Walala



Hello
It sems you still didn't forget that issue about how to stop a program
when the Terminal was gone )))))

Crontab isn't executed by you directly, it's an internal OS operation
and, it's made for executing commands whithout the need for someone to
be connected to the machine.

Just one more thing, if you want to block SPAM, you could try and look
at SIEVE rules ( rfc 3028).

Also, be carefull because crontab doens't have your $PATH defined.


Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jaime Cardoso <jaimec@solsuni.pt> wrote ...

{ snip }
quote:

> Also, be carefull because crontab doens't have your $PATH defined.



So I was always told, but found to my amazement that a 'cat' placed into my
crontab file, was executed ...

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6aJxGiD+5zjSqyTEQL7lgCdERqFuVPYgQAi
iiE7W0p2oexP0LQAoL33
3P0tsducas4ZXPw5XpZmkIvd
=akgk
-----END PGP SIGNATURE-----
Dave Hinz

2004-01-23, 5:07 pm

On Mon, 3 Nov 2003 19:00:53 +0100, Desmond Coughlan <pasdespam_desmond@zeouane.org> wrote:
quote:

> Jaime Cardoso <jaimec@solsuni.pt> wrote ...
>
> So I was always told, but found to my amazement that a 'cat' placed into my
> crontab file, was executed ...



Hint: which cat

Mike Delaney

2004-01-23, 5:07 pm

On Mon, 3 Nov 2003 19:00:53 +0100 in <lnhi71-lrh2.ln1@zeouane.org>,
Desmond Coughlan said something similar to:
:
: Jaime Cardoso <jaimec@solsuni.pt> wrote ...
:
: > Also, be carefull because crontab doens't have your $PATH defined.
:
: So I was always told, but found to my amazement that a 'cat' placed into my
: crontab file, was executed ...

Cron doesn't have _your_ $PATH defined, it does have _a_ $PATH defined,
usually something simple like /bin:/usr/bin. The salient point here
is that just because the program/script works when you run it from your
shell interactively, doesn't mean it'll work from cron where all of
your custom environment settings aren't present.
Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Hinz <davehinz@spamcop.net> wrote ...
quote:

[QUOTE][color=darkred]
[QUOTE][color=darkred]
> Hint: which cat



Good question.

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6eF6WiD+5zjSqyTEQJO1ACbBNXB4gypPvV+
TAGf3FAcEURWz4wAn1F2
W60nlMEUFbDOyj3BDezZCI3w
=tqfu
-----END PGP SIGNATURE-----
Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike Delaney <mdelan@computer.org> wrote ...
quote:

> : > Also, be carefull because crontab doens't have your $PATH defined.


quote:

> : So I was always told, but found to my amazement that a 'cat' placed
> into my : crontab file, was executed ...


quote:

> Cron doesn't have _your_ $PATH defined, it does have _a_ $PATH defined,
> usually something simple like /bin:/usr/bin. The salient point here is
> that just because the program/script works when you run it from your
> shell interactively, doesn't mean it'll work from cron where all of your
> custom environment settings aren't present.



Curiously enough, the 'bin' that I ran was in $HOME/bin ...

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6eGtmiD+5zjSqyTEQKKyQCgvbtDIX2Ig9LN
u83BfwuOqoUAWO8AoOKG
TsqlZSqxMmdHP+gSbwPoBDkX
=6/Z5
-----END PGP SIGNATURE-----
Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Desmond Coughlan <pasdespam_desmond@zeouane.org> wrote ...
quote:

[QUOTE][color=darkred]
[QUOTE][color=darkred]
[QUOTE][color=darkred]
> Curiously enough, the 'bin' that I ran was in $HOME/bin ...



Reading that back to myself, it's not clear. What I meant was that I
had...

0 0 * * * checknews

....in my crontab file, and it ran perfectly. 'checknews' is in $HOME/bin.

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6eJD2iD+5zjSqyTEQIiagCfcErseJD7R24C
YRtT+uVayMBoIfYAoJ6r
wbGfnPMN6C6gW4akX2ilD7Fv
=KaQ1
-----END PGP SIGNATURE-----
Jaime Cardoso

2004-01-23, 5:07 pm

quote:

>
>
>
> Good question.



Yes, that is correct. Crontab doesn't get YOUR PATH but, it has a PATH
of it's own and, there is a file somewhere where you can define
crontab's PATH
"man crontab" for more information

Barry Margolin

2004-01-23, 5:07 pm

In article <0ihk71-mq21.ln1@zeouane.org>,
Desmond Coughlan <pasdespam_desmond@zeouane.org> wrote:
quote:

>Reading that back to myself, it's not clear. What I meant was that I
>had...
>
> 0 0 * * * checknews
>
>...in my crontab file, and it ran perfectly. 'checknews' is in $HOME/bin.



There's probably another one in one of the standard system directories.
Cron definitely does *not* run your .profile automatically, so it doesn't
get a personalized $PATH.

--
Barry Margolin, barry.margolin@level3.com
Level(3), Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.
Mike Delaney

2004-01-23, 5:07 pm

On Tue, 4 Nov 2003 13:10:08 +0100 in <0ihk71-mq21.ln1@zeouane.org>,
Desmond Coughlan said something similar to:
:
: Reading that back to myself, it's not clear. What I meant was that I
: had...
:
: 0 0 * * * checknews
:
: ...in my crontab file, and it ran perfectly. 'checknews' is in $HOME/bin.

Assuming you haven't overlooked the presense of another copy of checknews
in one of the system bin directories, it's entirely possible that your
system's crond is being more helpfull than is traditional, or perhaps
the shell it's using to actually run the job is parsing its startup files
even though it's a non-interactive shell.
Desmond Coughlan

2004-01-23, 5:07 pm

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Barry Margolin <barry.margolin@level3.com> wrote ...
quote:

[QUOTE][color=darkred]
> There's probably another one in one of the standard system directories.
> Cron definitely does *not* run your .profile automatically, so it doesn't
> get a personalized $PATH.



It doesn't matter now, really, as I always use the full path nowadays. :-)

- --
Desmond Coughlan |desmond [at] zeouane [dot] org
http://www.zeouane.org/

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
Charset: noconv

iQA/ AwUBP6fwymiD+5zjSqyTEQKdYACfUsahRzMWnPmq
pVeeLyVuMAK4ohsAoINn
wImwLbAB3ytde8oIK4wAIlk0
=+kiu
-----END PGP SIGNATURE-----
S. Anthony Sequeira

2004-01-23, 5:07 pm

On Tue, 04 Nov 2003 01:09:35 +0000, Dave Hinz penned:
quote:

> On Mon, 3 Nov 2003 19:00:53 +0100, Desmond Coughlan
> <pasdespam_desmond@zeouane.org> wrote:
>
> Hint: which cat



Schroedingers of course ;)
--
Tony

Dave Hinz

2004-01-23, 5:07 pm

On Tue, 04 Nov 2003 21:36:05 +0000, S. Anthony Sequeira <tony@sequeira.com> wrote:
quote:

> On Tue, 04 Nov 2003 01:09:35 +0000, Dave Hinz penned:
>
>
> Schroedingers of course ;)



Maybe...maybe not... he won't know until he looks now, will he.

Dave "or maybe not" Hinz

S. Anthony Sequeira

2004-01-23, 5:08 pm

On Wed, 05 Nov 2003 04:26:58 +0000, Dave Hinz penned:
quote:

> On Tue, 04 Nov 2003 21:36:05 +0000, S. Anthony Sequeira
> <tony@sequeira.com> wrote:
>
> Maybe...maybe not... he won't know until he looks now, will he.
>
> Dave "or maybe not" Hinz



Perhaps
--
Tony

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2009 webservertalk.com