Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-25-2010, 11:44 AM
|
#1
|
|
Member
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX
Posts: 565
Rep:
|
BASH: Add cron job to run hourly
Hey guys, I have an rsync script I wrote that I have tested and it works perfectly when I run it manually. Now I am working on a server setup script and I have gotten my setup script to create the rsync script in /etc/cron.hourly and restart crond. To spite the fact that the script is in /etc/cron.hourly and I have restarted crond, the script does not run.
With that said, how can I script adding the rsync script to run hourly as a cron job?
|
|
|
|
03-25-2010, 12:46 PM
|
#2
|
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,474
|
Is the file executable?
|
|
|
|
03-25-2010, 01:23 PM
|
#3
|
|
Member
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX
Posts: 565
Original Poster
Rep:
|
yes, chmod 0755
|
|
|
|
03-25-2010, 02:05 PM
|
#4
|
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,474
|
Is cron.hourly running?
|
|
|
|
03-25-2010, 02:09 PM
|
#5
|
|
LQ 5k Club
Registered: May 2001
Location: Belgium
Distribution: Slackware 14.0
Posts: 8,464
|
Since cron has a limited path, make sure to give the whole path to the commands and files.
Normally root should recieve an email if any problems.
Take a look in the log files for some pointers.
|
|
|
|
03-25-2010, 03:25 PM
|
#6
|
|
Member
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX
Posts: 565
Original Poster
Rep:
|
Quote:
Originally Posted by AlucardZero
Is cron.hourly running?
|
I do not know. I guess I should check that
Quote:
|
Originally Posted by Repo
Since cron has a limited path, make sure to give the whole path to the commands and files.
Normally root should recieve an email if any problems.
Take a look in the log files for some pointers.
|
It is a single command and it uses absolute path names so thats not a problem.
|
|
|
|
03-25-2010, 03:40 PM
|
#7
|
|
Member
Registered: Apr 2006
Location: Washington
Distribution: Suse, CentOS, Ubuntu
Posts: 124
Rep:
|
Show current cronjobs:
crontab -l
edit cronjobs with default editor:
crontab -e
http://en.wikipedia.org/wiki/Cron
|
|
|
|
03-25-2010, 03:41 PM
|
#8
|
|
LQ 5k Club
Registered: May 2001
Location: Belgium
Distribution: Slackware 14.0
Posts: 8,464
|
Perhaps you can post the cronjob or script?
|
|
|
|
03-26-2010, 05:03 AM
|
#9
|
|
Member
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381
Rep:
|
Redirect the standard error and stdout to file to capture the out and error log, that will help in moving to the right direction
Code:
* */1 * * * /path/to/script/script 1>>/tmp/script.out 2>>/tmp/script.err
|
|
|
|
03-26-2010, 10:36 AM
|
#10
|
|
Member
Registered: Oct 2004
Location: Atlanta
Distribution: CentOS, RHEL, HP-UX
Posts: 565
Original Poster
Rep:
|
I got it sorted out. Not sure why it wasn't running but I simply wrote a entry into /etc/crontab and the restarted crond and it works. I know you are supposed to use crontab -e to add jobs but that does it for a user, this way I can script it and have the system run it as root.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:42 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|