LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 09-10-2009, 05:13 PM   #1
cpthk
Member
 
Registered: Aug 2009
Posts: 31

Rep: Reputation: 15
linux cron job duplicate job question


Hi:

I am setting up linux cron job. I was wondering if I set the cron job to wake up every minute. My process may take several minutes. Will there be a duplicate process issue?

For example, I am running a.out program. This program in busy load may take 5 minutes to finish. I need to set my corn job to run every minute. Will the linux cron run before the previous one finishes? Or it will wait for the previous one to finish? Or it will not run at all if the previous is still running?

I really need to set the cron as every minute for particular reason. Even I set it for a longer time, the program could still run longer than that depends on the load.

Thanks.
 
Old 09-10-2009, 05:21 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,404

Rep: Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529
Quote:
Originally Posted by cpthk View Post
Hi:

I am setting up linux cron job. I was wondering if I set the cron job to wake up every minute. My process may take several minutes. Will there be a duplicate process issue?

For example, I am running a.out program. This program in busy load may take 5 minutes to finish. I need to set my corn job to run every minute. Will the linux cron run before the previous one finishes? Or it will wait for the previous one to finish? Or it will not run at all if the previous is still running?

I really need to set the cron as every minute for particular reason. Even I set it for a longer time, the program could still run longer than that depends on the load.

Thanks.
No, it will spawn another job, and you'll have several all running at the same time.

And setting up a process that you know will take longer than a minute to complete, to run every minute, seems like a bad idea. Why don't you put a sleep statement into your script, so it'll pause for one minute, after each run? Then just run it with "nohup <script name> >/dev/null &", and it'll background and run just fine.
 
Old 09-10-2009, 05:43 PM   #3
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,261

Rep: Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028Reputation: 2028
As per TB0ne, every minute is overkill and will hammer your system creating a whole new process environment each time.
Plus, if they're processing the same data, it'll screw up.
Create a daemon as he said; personally I'd add logging, so

nohup prog >prog.log 2>&1 &
 
Old 09-11-2009, 07:04 PM   #4
cpthk
Member
 
Registered: Aug 2009
Posts: 31

Original Poster
Rep: Reputation: 15
I am actually running a perl script. The perl script will call a c++ program. So in perl script how do I sleep for a minute?
 
Old 09-11-2009, 08:52 PM   #5
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 14,404

Rep: Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529Reputation: 2529
Quote:
Originally Posted by cpthk View Post
I am actually running a perl script. The perl script will call a c++ program. So in perl script how do I sleep for a minute?
sleep(<seconds to sleep);

Check perldoc or CPAN for more info.
 
  


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cron job question s_linux Linux - General 1 07-23-2009 12:17 PM
cron job question kashyapvirgo Linux - General 6 02-24-2007 01:07 AM
Cron job question a2vr6 Linux - Newbie 8 11-17-2006 01:33 PM
Cron Job Question tarballed Linux - Newbie 4 06-20-2006 03:39 PM
Cron Job Question abhijeetudas Linux - Software 2 03-01-2006 11:27 PM


All times are GMT -5. The time now is 03:27 PM.

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