LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
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 08-31-2009, 02:12 PM   #1
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 143

Rep: Reputation: 15
crontab job not executing....


guys, I scheduled a job to backup my system in crontab and I'm using "dump" to do the backup, but for some reason the job is not starting. Here's the line in crontab

Code:
30 4 30 * * * root dump -0aj -f /mnt/storage/backup/linuxfull.bak /

any help appreciated
 
Old 08-31-2009, 02:16 PM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,484

Rep: Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882
Does it work from the command prompt?
any error messages?
Try to use the whole path to the command.
eq
/sbin/dump
 
Old 08-31-2009, 02:22 PM   #3
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 143

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by repo View Post
Does it work from the command prompt?
any error messages?
Try to use the whole path to the command.
eq
/sbin/dump
yes it works fro the shell... same exact command. I'll try that next, however, notice that I'm running this command as root, and I have ran it as root from the command line, so I think that the path is not an issue here
 
Old 08-31-2009, 02:22 PM   #4
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,453

Rep: Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941Reputation: 1941
1. Check /var/log/cron for some useful message.
2. Check the standard output and the standard errors from the cron job (if any). Since you didn't redirect them to a file, most likely they have been sent by e-mail: check them from a terminal using the mail command.
3. If this is a user's crontab (root included) you don't have to put the username in the cron entry, that is remove "root" from the line you posted above.
4. Use full path for every command run in crontab. Check it using which dump and add it to the entry. This is because cron has a very limited environment - different from that set-up at user's login - and PATH is limited to /bin:/usr/bin.
5. Please, post any relevant result from points 1 to 4 above.
 
Old 08-31-2009, 02:24 PM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Linux Mint
Posts: 8,484

Rep: Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882Reputation: 882
cron has its own path, it is not the default path.
A good rule is to use the complete path to all commands and files
 
Old 08-31-2009, 02:27 PM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,524
Blog Entries: 27

Rep: Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175Reputation: 1175
The usual "gotchas" are 1) that the environment provided by cron is not the same as the login environment, especially not having the usual $PATH is a problem and 2) any output from the script to stderr or stdout (that would normally go to the terminal) have nowhere to go and cron stops the job.

You can test whether 1) is the problem by changing the first line of the script to
Code:
#!/bin/bash -l
That's a letter l and tells bash to run the login process thus setting up the "usual" environment.

Solving 2) is a matter of redirecting any output to a file (maybe /dev/null) using something like > <some file> and 2>&1 (which directs stderr to the same place as stdout).
 
Old 08-31-2009, 02:42 PM   #7
mia_tech
Member
 
Registered: Dec 2007
Location: FL, USA
Distribution: CentOS 5.3, Ubuntu 9.04
Posts: 143

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by colucix View Post
1. Check /var/log/cron for some useful message.
2. Check the standard output and the standard errors from the cron job (if any). Since you didn't redirect them to a file, most likely they have been sent by e-mail: check them from a terminal using the mail command.
3. If this is a user's crontab (root included) you don't have to put the username in the cron entry, that is remove "root" from the line you posted above.
4. Use full path for every command run in crontab. Check it using which dump and add it to the entry. This is because cron has a very limited environment - different from that set-up at user's login - and PATH is limited to /bin:/usr/bin.
5. Please, post any relevant result from points 1 to 4 above.
This is the root crontab file. I originally didn't especify the root in the file, but because it didn't run, I thought it might have been the absence of root, so I added it...

ok, I'll remove root and add /sbin/dump, and no, I have not checked mail or cron logs... I'll do that next. Should have been the first thing, but slipped my mind
 
  


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
the crontab job is not run ust Linux - Software 1 03-24-2008 07:03 PM
Command for executing C program in crontab bhandu Linux - Newbie 1 07-14-2007 12:54 PM
Run crontab job sunhui Linux - Software 2 05-16-2007 08:35 PM
crontab job Thulemanden Linux - Software 2 07-09-2006 06:57 AM
crontab job entry notolerance Linux - Software 2 02-20-2005 02:40 PM


All times are GMT -5. The time now is 08:53 AM.

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