LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
LinkBack Search this Thread
Old 05-08-2010, 03:16 PM   #1
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 438

Rep: Reputation: 17
cron jobs for less than a minute


hello
how can I cron jobs for less than a minute for example configuring cron job to do something for each 15 seconds.
 
Old 05-08-2010, 04:22 PM   #2
frostschutz
Member
 
Registered: Apr 2004
Distribution: Gentoo
Posts: 63

Rep: Reputation: 16
cron jobs is meant for stuff that runs every couple of hours, or even days, weeks, months, so doing something every minute is the best it can do

if you want to do something every 15 seconds, you could make a shell script and sleep instead

Code:
while [ 1 ]
do
    something
    sleep 15
done
 
1 members found this post helpful.
Old 05-09-2010, 02:42 AM   #3
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 438

Original Poster
Rep: Reputation: 17
Is any way except that? it makes busy waiting for that.
 
Old 05-09-2010, 04:18 AM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371Reputation: 2371
Hi,

The shortest time interval you can use with cron is 1 minute.

frostschutz's solution works, although you will introduce a sliding window (the next run will be 15 seconds + runtime of "something").

Hope this helps.
 
1 members found this post helpful.
Old 05-09-2010, 06:55 AM   #5
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
The sleep command does NOT busy wait, at least my version doesn't. I just tried it.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
cron at every 51st minute cooljai Linux - Software 7 02-23-2009 06:49 AM
cron hourly, daily, cron.d jobs don't execute eggsmartha Linux - General 3 09-17-2007 06:37 PM
cron jobs bilal_linux Linux - Software 10 04-25-2007 07:49 AM
Cron Jobs christo512 Linux - Software 1 02-09-2006 09:19 AM
5 minute cron jobs for mrtg and gate_news shawn_t Linux - Software 3 12-22-2004 05:23 PM


All times are GMT -5. The time now is 03:50 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration