|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now! |
|
#1
|
|||
|
|||
|
Shell script doesn't work as cron job
This code works correctly when executed from the command line, but when I have this entry in my crontab file the output is an empty bz2 file.
cron tab: Code:
@daily /usr/home/wha/scripts/rperry_wha_bkup.sh shell script: Code:
#!/bin/sh # Script name : auto_mysql_dump.sh # Backup the dbname database dir=`date +%Y-%m-%d` dbname='rperry_wha' if [ -d /home/wha/backup ]; then mkdir /home/wha/backup/$dir mysqldump -B --user=rperryFile --password=somepassword --host=127.0.0.1 $dbname | bzip2 -c > /home/wha/backup/$dir/$dbname.sql.bz2 fi # End of script auto_mysql_dump.sh
__________________
Were my suggestions helpful? If so, please click the above this post.
|
|
#2
|
|||
|
|||
|
Use absolute path names.
Cron has got a different environment setup than your shell. The problem is most likely the PATH variable. M.
__________________
-- Manuel Hirsch - Linux, FreeBSD, programming, administration articles, tutorials and more. |
|
#3
|
|||
|
|||
|
this may not apply...so FWIW...
If you used a 'Windows' (or other non-nix) system to compose the shell script and then uploaded it to the server there is a possibility that there are hidden characters that get ignored when the script is run from bash but cron see it as a corrupted file... |
|
#4
|
|||
|
|||
|
Hmm, I tried to be careful with the path names, but maybe mysqldump is the issue. I'll use a full path on it and see what happens.
Thanks. |
|
#5
|
|||
|
|||
|
Yes, that's what I meant.
The "PATH" variable is the search path for binaries. It does not include /usr/local/bin by default. You can change this, but I prefer to use absolute paths still. M. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Shell script doesn't work as cron job |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|