Wednesday, November 14, 2012
Scheduling cron job to run in every 15 seconds.
Hi Guys,
Today the huddle I faced is to schedule a cron job in every 15 seconds. Normally or by default it is not possible to do that , because in crontab we don't have option to setup in seconds. It starts from minute. In my research I found the following way to overcome this situation.
1. Multiple entries in crontab,
* * * * * /home/faisal/Desktop/hello.sh
* * * * * (sleep 15; /home/faisal/Desktop/hello.sh)
* * * * * (sleep 30; /home/faisal/Desktop/hello.sh)
* * * * * (sleep 45; /home/faisal/Desktop/hello.sh)
2. Using while loop in script.
Schedule the job to run in every minute.
* * * * * /home/faisal/Desktop/hello.sh
Modify the script as follows,
#!/bin/bash
n=0
while [ $n -le 3 ]
do
DO WHATEVER YOU WANT
sleep 15
(( n++ ))
done
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment