Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> Cron Job To Run Every 20 Seconds, set up cron job to run every 20 seconds
iaina
post Sep 2 2003, 02:52 PM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 2-September 03
Member No.: 1,365



Hi,

Could somebody tell me how to set up a cronjob, for a RedHat Linux machine, that runs every 20 seconds?

I used the 'crontab' command to create the cronjab, and when I do 'crontab -l', the command that I entered is displayed. However, the job isn't running.

Thanks,
Iain
Go to the top of the page
 
+Quote Post
hughesjr
post Sep 2 2003, 03:30 PM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 3,433
Joined: 25-July 03
From: Corpus Chrsiti, TX, USA
Member No.: 1,151



Cron runs every minute ... so you can't run something more frequently than every minute ... and it starts at exactly 00 seconds.

There are five fields and the command to execute ... the fields are:
CODE
field          allowed values
-----          --------------
minute            0-59
hour               0-23
day of month   1-31
month             1-12 (or names, see below)
day of week     0-7 (0 or 7 is Sun, or use names)


it looks like this in an entry:

min hr dom mon dow command_to_execute

so

05 12 * * 3 /bin/test_script.sh

would start the script /bin/test_script.sh at 12:05pm every Wednesday
----------------------------------------
You could create 3 cron entries that look the same as the first one ... but they need to call 3 seperate files ...

file 1: does what you want...
file 2: has a line sleep 20 and all the stuff in file 1
file 3: has a line sleep 40 and all the stuff in file 1

the crontab entry would be:

0-59 * * * * path_to_file1
0-59 * * * * path_to_file2
0-59 * * * * path_to_file3

so file1 will execute on the minute at 00 seconds... file2 will start executing on the minute at 00, and sleep for 20 seconds then start ... file3 will execute at 00 and sleep for 40 seconds then execute.

Are you sure that what you want to do must be done every 20 seconds ... that seems very fast. Will the process be complete before it tries to start again? If not, you need to not start a process and potentially hang it until the other one is finished.


--------------------
Johnny Hughes
hughesjr@linuxhelp.net
Enterprise Alternatives: CentOS, WhiteBoxEL
Favorite Workstation Distros (in order): CentOS, Gentoo, Debian Sarge, Ubuntu, Mandrake, FedoraCore, Slackware, SUSE
Favorite Server Distros (in order): CentOS, WhiteBoxEL, Debian Sarge, Slackware, Mandrake, FedoraCore, Gentoo, SUSE
Go to the top of the page
 
+Quote Post
iaina
post Sep 2 2003, 04:18 PM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 2-September 03
Member No.: 1,365



Thanks for the response.

I just wanted to know if it was feasible. The other option would be to code the application so that it starts, sleeps for a designated period, and then continues running. That option would elimate the need for the cronjob altogether.
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd October 2017 - 09:41 PM