|
|
|
| |||||||||
![]() |
|
|
«
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
|
|||
|
|||
|
Cron isn't executing all commands
I have a script, daily.sh, that runs every day at 3 am
Code:
0 3 * * * /root/daily.sh When executed normally (./daily.sh) it works just fine. The problem is that when run by cron, it doesn't execute all of the commands in daily.sh. Even though cron is run by root. Code:
[root@utopia.XXXXXXX.XX] ~: cat daily.sh #!/bin/sh TS=`date "+%Y_%m_%d"` MYSQL_PATH="/var/db/mysql" WWW_PATH="/www" # This part is NOT being executed umount /dev/da0c dd if=/dev/zero of=/dev/da0 count=2 disklabel -Brw da0 auto newfs /dev/da0c >> /dev/null mount /dev/da0c /zip # This part is NOT being executed # This part IS being executed `cp -R -p $MYSQL_PATH /zip/$TS-mysql` # .. and a bunch of other cp's. # This part IS being executed I don't have anything in /var/cron/deny, and /var/log/cron doesn't say anything useful. Any ideas? |
|
#2
|
|||
|
|||
|
Try to add root like this..
Code:
0 3 * * * root /root/daily.sh |
|
#3
|
|||
|
|||
|
Cron took the "root /root/daily.sh"-part as one command, which, obviously, didn't work.
|
|
#4
|
||||
|
||||
|
is the file system in use when it tried to ge umounted?
__________________
microsofts butterfly is their way off telling u their systems have a **** load of buggs Advocating Linux Guide Lesbian Linux Great & Practical Computer Books like the links? |
|
#5
|
|||
|
|||
|
Nope.
|
|
#6
|
|||
|
|||
|
It's probably got to do with the environment that cron makes available to your script. Try running /usr/bin/env from the command line and see what the environment looks like. Then run the same command using cron. It's likely that the PATH in the cron environment is very different from the one you get on the command line.
For example, my command line PATH is: /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin And my cron PATH is: /usr/bin:/bin Most of the commands in the section of your code that isn't executing are in /sbin/. Hope that helps. |
![]() |
| Viewing: Dev Shed Forums > Operating Systems > BSD Help > Cron isn't executing all commands |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|