Issues while executing shell scripts through Cron job
First Script: one.sh
cat /data/backup/scripting/shell-scripts/cron-script/one.sh Quote:
cat /data/backup/scripting/shell-scripts/cron-script/two.sh Quote:
#cronjob -l * * * * * /data/backup/scripting/shell-scripts/cron-script/one.sh |
Is one.sh executable? How do you tell the script has not been executed? Take in mind that the command
Code:
touch $1.sh |
Doesn't it work if you make the two scripts executable and then just use them by their name (without "sh" in front...)?
Why would you do it the way you described? |
Yes both the files are executable.
I have changed the two files: cat /data/backup/scripting/shell-scripts/cron-script/one.sh Quote:
cat /data/backup/scripting/shell-scripts/cron-script/two.sh Quote:
# /data/backup/scripting/shell-scripts/cron-script/one.sh then "three" is being echoed & "three.sh" is also getting created in "/data/backup/scripting/shell-scripts/cron-script/" |
Is the cron daemon running? Did you receive any mail from the cron daemon?
|
Yep, check your email and or root's, depending on whose crontab this is.
However, just to point out that jobs in cron are not attached to a terminal, so 'echo' is a pointless cmd, unless you re-direct it to a file eg echo "$var1" >/dir/somefile Given that the default env/PATH var is minimal in cron, you should always specify the full path eg /bin/touch /path/file |
Thanks 2 all for your prompt replies........I got it resolved......It was a permission related issue....
|
I'm having the same problem with FreeBSD
What was the permissions issue, and how did you resolve it? I've got a pair of scripts that I'm trying to run via the root cron, but they don't execute, even though I updated the cron normally.
|
The path variable that is set under cronjob is different from the one that is set under normal circumstances i.e cronjob path variable is different from the one "#env | grep -i path"
So execute the shell script by specifying full path name of the commands or explicitly export the path variable. |
All times are GMT -5. The time now is 10:40 PM. |