Run script from cron - problem
Hii
Im having some difficulties with running a shell script from cron which I am unable to resolve for almost 2 days now. For testing purposes, im trying this with simple shell script test.sh with chmod 777 ------ test.sh ------ #!/bin/sh # echo asdasdasd ------ This script is located at /var When I type /var/test.sh it runs perfectly and prints asdasdasd When I type /var/test.sh > /home/log it writes asdasdasd to /home/log - works The problem occurs whenever I add it as a cron job to var/spool/cron/crontab/root there is: 11 10 * * * /var/test.sh > /home/log - however, at 10:11 there is no file at /home/log Cron as a service works, forexample, every day at 4 am it makes this backup sshpass -p xxxx rsync -avz -e ssh root@x.x.10.7:/data/backup/ /home/backups/isp_admin However, 13 00 * * * cd /home mkdir asdasd doesnt makes the folder Where is the catch? Thanksssss |
Hi and welcome to LinuxQuestions! :)
The syntax is correct and indeed it should work, provided the crontab's owner has permissions to write in /home. You can check three things: 1. see if the cron log actually reports the execution of your job. Usually it is /var/log/cron and you should see an entry like this: Code:
Jul 1 10:11:02 hostname crond[29083]: (username) CMD (/var/test.sh > /home/log) 3. see if the crontab's owner has permissions to run cron jobs. You can check the /etc/cron.deny and /etc/cron.allow files. In any case, who is the crontab's owner? A regular user or root? And how did you edit the crontab (using the command crontab -e or something else)? Edit: please note that the mkdir entry is wrong instead. It should be something like: Code:
0 13 * * * cd /home && mkdir asdasd |
Quote:
the problem was that I used winscp and editted var spool cron crontab root file, instead of crontab -e |
All times are GMT -5. The time now is 09:40 PM. |