Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 12-07-2007, 07:03 PM   #1
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
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
Submit an at job instead.
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
LQ Guru
Registered: Feb 2003
Location: Virginia, USA
Distribution: Debian 11
Posts: 8,262

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


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 > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:45 PM.

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