LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron Job: Start it Only once on specified time (https://www.linuxquestions.org/questions/linux-newbie-8/cron-job-start-it-only-once-on-specified-time-605281/)

jCash 12-07-2007 07:03 PM

Cron Job: Start it Only once on specified time
 
I want cron job to start the script on a specified time, i.e 9:00am, and it started only once. Because this script runs forever as long as there is no system boot up. I just want to start this script on the OS only once, if it is not already started, on a specified time. Script will be runnig forever without terminating.

Any idea how I can do this in cron?

Berhanie 12-07-2007 07:05 PM

Submit an at job instead.
Code:

man at
[edit]Scratch that. You don't know when you'll have to run it. You can have a cron job run at 9:00 daily, and check to see if the thing is running, and run it only if it's not.

jailbait 12-07-2007 07:35 PM

You could use a lock file. When the cron script starts it checks to see if the lock file exists. If the lock file exists the cron scripts exits. If the lock file does not exist then the script creates the lock file and continues to run.

Then you need a second script which runs on each boot and deletes the lock file.

------------------
Steve Stites


All times are GMT -5. The time now is 02:57 PM.