dslreports logo
site
 
    All Forums Hot Topics Gallery
spc

spacer




how-to block ads


Search Topic:
uniqs
682
share rss forum feed


zacron
Premium
join:2008-11-26
canada

[nix hosting] Looking to make this crontab entry work on ubuntu

* * * * * root php /var/www/agents/ping.php web > /dev/null
* * * * * root php /var/www/agents/ping.php > /dev/null

I want to make it run every 5 seconds... how do I set that up?

Thanks,

Zacron
--
"Recognize, Realize, and Repent"

aguen
Premium
join:2003-07-16
Grants Pass, OR
kudos:2

Re: [nix hosting] Looking to make this crontab entry work on ubu

from the cli man crontab


hawk82

join:2001-04-26
centralmaine
reply to zacron


Defiance82
Computer Elite
Premium
join:2002-09-11
Burlington, WI
Reviews:
·Time Warner Cable

1 edit
reply to zacron
Cron job cannot be used to schedule a job in seconds interval. i.e You cannot schedule a cron job to run every 5 seconds. The alternative is to write a shell script that uses sleep 5 command in it.

Or you can run it every minute by using the following

* * * * *

Create a shell script every-5-seconds.sh using bash while loop as shown below.

$ cat every-5-seconds.sh
#!/bin/bash
while true
do
/home/user/script.sh
sleep 5
done

Now, execute this shell script in the background using nohup as shown below. This will keep executing the script even after you logout from your session. This will execute your backup.sh shell script every 5 seconds.

nohup ./every-5-seconds.sh &

Plus most hosts would forbid a 5 second script as you would suck up to many resources depending on what your doing.
--
Affordable Web-Hosting, Reseller Hosting, Ventrilo, & Teamspeak services since 1999 @ »www.deadlyservers.com

Asus RT-AC66R / Motorola SB6121