Re: Emulate(?) the crontab

Benoît Rouits <[email protected]>
Newsgroups org.kernel.vger.linux-admin
Message-ID <1168378445.7063.14.camel@chimay>
Le mardi 09 janvier 2007 à 19:33 +0000, Mário Gamito a écrit :
> Hi,
[...]
> The agregator software must run a one line command every 15 minutes to 
> rebuild the index.html of the site.
If you have a remote shell access with a "root" account, you do can
edit the system crontab. Edit file /etc/crontab and put a line like the
following, with the hope this is not a standard old cron but a Vixie
cron thus allowing 15 minutes:

*/15 *  * * *   root    /ACCESS/TO/planet.py /ACCESS/TO/geek/fancy/config.ini

if you have only a webmaster account, edit your own crontab with
command "crontab -e" and do not put the "root" field.

> The command is
> #planet.py geek/fancy/config.ini
> 
[...]
> I wonder if there could be written a script (bash, perl, python), that 
> *without crontab* could run the command I need.

A nice choice is a "while" loop and a "sleep" inside it. for instance:
edit file looplanet.sh:

#!/bin/sh
SECONDS=`expr 60 \* 15`
while true
do
    /ACCESS/TO/planet.py /ACCESS/TO/geek/fancy/config.ini
    sleep $SECONDS
done
#end of file

then "chmod" it to make it read+executable:
bash [~/bin] # chmod 755 looplanet.sh
then launch it with "nohup" or "setsid" and ensure it can run
once you are logged out.
bash [~/bin] # nohup ./looplanet.sh &
[...nohup telling where it stores output]
bash [~/bin] # exit

> Any help would be appreciated.
Hope the above helped. There is no more way regarding given infos.
> 
> Warm Regards,
> Mário Gamito
> -
> To unsubscribe from this list: send the line "unsubscribe linux-admin" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-
To unsubscribe from this list: send the line "unsubscribe linux-admin" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.