LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 02-02-2005, 10:24 AM   #1
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Rep: Reputation: 30
Schedule a Script to Run


I have written a script to perform a backup. I would like it to run every day, but I don't want it sitting in a loop 24/7 waiting to run. Is there a way to schedule it to run once a day?

Thanks
 
Old 02-02-2005, 10:27 AM   #2
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 31
Put it into your /etc/cron.daily file.
 
Old 02-02-2005, 10:29 AM   #3
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
Wow is it that easy!? Can I just dump the script in, or is there more configuring?
 
Old 02-02-2005, 10:29 AM   #4
zaichik
Member
 
Registered: May 2004
Location: Iowa USA
Distribution: CentOS
Posts: 419

Rep: Reputation: 30
Do you have shell access? If so, you could schedule it as a cron job.

Depending on your distro, it might go something like this...

At the command line, type

crontab -e

This will open the cron table in an editor, like vi or nano or something. Then add this line:

* 2 * * * /path/to/script/scriptname

This would run the script at 2 AM every day. For help on cron jobs, Google "cron tutorial".

Hope that helps.
 
Old 02-02-2005, 10:33 AM   #5
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
Thanks zaichik, that looks like just what I need.
 
Old 02-02-2005, 10:39 AM   #6
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
zaichik - One last thing, I've had a look at the tutorials and have made my entries into crontab, but I can't find if I have to restart crontab to get it to pickup my changes. Is a crontab restart necessary and how is it done?

Thanks again
 
Old 02-02-2005, 10:49 AM   #7
zaichik
Member
 
Registered: May 2004
Location: Iowa USA
Distribution: CentOS
Posts: 419

Rep: Reputation: 30
Nope, restarting cron is not necessary, you should be good to go. As always when you are backing data up, check to make sure the backup actually ran--don't just trust that there is not something wrong with the script or something else!
 
Old 02-02-2005, 10:52 AM   #8
Linux~Powered
Member
 
Registered: Jan 2004
Location: /lost+found
Distribution: Slack`er-current
Posts: 845

Rep: Reputation: 31
To kill cron and restart it
Code:
pkill cron && crond
 
Old 02-02-2005, 12:37 PM   #9
nutthick
Member
 
Registered: Jun 2004
Distribution: Slack
Posts: 214

Original Poster
Rep: Reputation: 30
zaichik - Thanks for the tip, I'm having to rewrite it because of the previous backups failure.
 
  


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
Schedule a script every three hours dkochan Linux - General 1 03-07-2004 10:18 AM
schedule 'e2fsck' to run on startup, possible? BxBoy Linux - General 1 02-18-2004 12:15 PM
on Network Up Script run? On Battery power run script? v2-ncl Linux - General 0 12-08-2003 09:34 AM
schedule job to be run at 8:00pm every night ashley75 Linux - General 22 10-24-2003 12:44 PM
how do i schedule events to run daily. ThaddNZ2003 Linux - General 2 03-10-2003 10:59 AM


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