LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
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
  Search this Thread
Old 05-08-2010, 03:16 PM   #1
golden_boy615
Member
 
Registered: Dec 2008
Distribution: Ubuntu Fedora
Posts: 445

Rep: Reputation: 18
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: 95

Rep: Reputation: 28
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: 445

Original Poster
Rep: Reputation: 18
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: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
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: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723Reputation: 723
The sleep command does NOT busy wait, at least my version doesn't. I just tried it.
 
1 members found this post helpful.
  


Reply



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



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 05:35 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration