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 12-07-2007, 07:03 PM   #1
jCash
Member
 
Registered: Sep 2006
Posts: 57

Rep: Reputation: 15
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?
 
Old 12-07-2007, 07:05 PM   #2
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
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.

Last edited by Berhanie; 12-07-2007 at 07:09 PM.
 
Old 12-07-2007, 07:35 PM   #3
jailbait
Guru
 
Registered: Feb 2003
Location: Blue Ridge Mountain
Distribution: Debian Wheezy, Debian Jessie
Posts: 7,536

Rep: Reputation: 178Reputation: 178
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
 
  


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
adding a perl script to cron.daily / cron.d to setup a cron job CrontabNewBIE Linux - Software 6 01-14-2008 08:16 AM
cron job somsahi Linux - Software 2 10-24-2006 05:40 AM
need help with cron job parthcorp1 Linux - General 2 02-01-2005 11:37 AM
Howto run a job on a fixed time with cron? Schmurff Linux - Newbie 1 04-02-2004 03:31 AM
cron job? luap Linux - Software 2 03-16-2003 08:48 AM


All times are GMT -5. The time now is 04:02 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