Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum. |
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.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
05-18-2006, 10:30 PM
|
#1
|
LQ Newbie
Registered: Oct 2005
Posts: 12
Rep:
|
Issue with dump / cron
Greetings.
I currently am running a server which has recently been augmented with a tape backup system (model info below). I have written a very simple bash script to run backups (scripts contents below), and running this from the command line yields a successful backup. I have tested this manually many times, and all disaster-recovery tests have been 100% successful.
So I have added this to my crontab (shown below), which has two other jobs scheduled that run perfectly. For the life of me, I CANNOT get my backup script to run automatically via cron (which I have previously mentioned runs PERFECTLY from the command line).
I have checked /var/log/cron and it indeed says the job has run. However, the job clearly does NOT run, because 'dump' never appears as a running process in 'top' or 'ps'.
Permissions are fine (the other two jobs have identical permissions, execute-bits and ownership). Root owns the files, and it is root's crontab which executes these jobs. Running the command with 'at' works fine as well, I just prefer cron.
Here is my current system:
Tape Backup Unit:
Sony SDX-260V IDE
Using 21/50 GB tapes
'/root/root.crontab' contents:
00 21 * * * /SCRIPTS/dump_current_mail.sh <--- runs GREAT
05 22 * * * /SCRIPTS/mail_transfer.sh <--- also runs GREAT
00 23 * * * /SCRIPTS/backup.sh <--- WILL NOT RUN WITH CRON
Crontab is activated using 'crontab root.crontab' at the bash prompt as root. This is the way I have always done it, and ALL the other machines I run use this method and I do not have this problem with any of them.
'/SCRIPTS/backup.sh' contents:
mt -f /dev/tape eod <--- Go to end of data on this tape
dump -f /dev/tape /MASTER/Data/ <--- dump this dir to this tape drive
dump -f /dev/tape /MASTER/MAIL <--- dump this dir to this tape drive
For those of you who know 'dump', this is incredibly simple (I am no expert with 'dump'). These commands work perfectly as individual commands, AND they work perfectly when this script is executed MANUALLY.
I am out of ideas. Any help would be appreciated, as I am having to do these backups manually every night =)
Thanks
subcon
|
|
|
05-18-2006, 11:01 PM
|
#2
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
One test you could try is to run the script manually but in the background.
If it doesn't run, you may need to redirect the output to /dev/null, or take stdin from /dev/zero.
You could try redirecting the output to /dev/null in the script.
|
|
|
05-18-2006, 11:22 PM
|
#3
|
LQ Newbie
Registered: Oct 2005
Posts: 12
Original Poster
Rep:
|
Running the script with & at the end ran, however doing so in crontab yielded no result. I even made a separate script, called execute_backup.sh with the following contents:
/SCRIPTS/backup.sh 2&1> /dev/null
|
|
|
05-18-2006, 11:56 PM
|
#4
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Try adding 2&>/dev/null to the cron command itself
00 23 * * * /SCRIPTS/backup.sh 2&>/dev/null
|
|
|
05-19-2006, 12:11 AM
|
#5
|
LQ Newbie
Registered: Oct 2005
Posts: 12
Original Poster
Rep:
|
=( Still no luck. 'top' shows no evidence of dump being run. This is so weird ...
|
|
|
05-19-2006, 01:10 AM
|
#6
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,434
|
iirc, the PATH used by cron is very minimalist ie it's poss that the tape cmds are not in the avail path. Try
echo $PATH
at the top of the shell script.
A way to debug it (shell file) is to say
set -xv
as the 2nd line (ie 1st after shebang line) of the shell script.
|
|
|
05-19-2006, 01:19 AM
|
#7
|
LQ Newbie
Registered: Oct 2005
Posts: 12
Original Poster
Rep:
|
I'll try that in the morning, I'm about to pass out. Thanks guys ....
|
|
|
05-19-2006, 01:40 AM
|
#8
|
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
Nice catch, subcon!
Instead of redirecting the output, perhaps you should redirect it to a file. Both the stdout and stderr streams. At least until you have it working.
This may provide information on what is going wrong.
I took a look at my /etc/crontab file.
Code:
SHELL=/bin/sh
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
# check scripts in cron.hourly, cron.daily, cron.weekly, and cron.monthly
#
-*/15 * * * * root test -x /usr/lib/cron/run-crons && /usr/lib/cron/run-crons >/dev/null 2>&1
If "dump" isn't in the path, you can add the path in a PATH= command.
Last edited by jschiwal; 05-19-2006 at 02:25 AM.
|
|
|
05-25-2006, 12:25 AM
|
#9
|
LQ Newbie
Registered: Oct 2005
Posts: 12
Original Poster
Rep:
|
Thank You
IT WORKED.
The end result (backup.sh):
SHELL=/bin/bash
PATH=/usr/bin:/usr/sbin:/sbin:/bin:/usr/lib/news/bin
MAILTO=root
#
mt -f /dev/tape eod
echo BEFORE DUMP: `date +%A-%Y.%m.%d` `mt tell` >> /root/backup_status.log
dump -f /dev/tape /MASTER/Data/
dump -f /dev/tape /MASTER/MAIL/
echo AFTER DUMP: `date +%A-%Y.%m.%d` `mt tell` >> /root/backup_status.log
THANK YOU THANK YOU
subcon
|
|
|
All times are GMT -5. The time now is 06:19 AM.
|
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
|
|