LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   some cronjobs don't work (https://www.linuxquestions.org/questions/linux-newbie-8/some-cronjobs-dont-work-639969/)

xpucto 05-05-2008 03:37 AM

some cronjobs don't work
 
Hi!

I wrote a backup script that I want to run with cron.
so I did in crontab -e
Code:

0 3 * * * /root/scripts/backup-myserver
But nothing happened.
I tested my script:
Quote:

sudo /root/scripts/backup-myserver
It works.
I tested my cron daemon:
Quote:

37 10 * * * /bin/touch /home/myuser/backup-scripts/test-cron-050508
it also works.
So if my script works and if cronjobs work, where is the problem?!

billymayday 05-05-2008 03:44 AM

Is this root's crontab or another user's? If it isn't root's, you probably have a permissions issue since the script is in root's home.

xpucto 05-05-2008 04:27 AM

Quote:

Originally Posted by billymayday (Post 3143077)
Is this root's crontab or another user's? If it isn't root's, you probably have a permissions issue since the script is in root's home.

it is root crontab.
Quote:

sudo crontab -e
I also put the script in my user's home's directory. But it didn't change anything.
and touch in root directory also works:
Quote:

32 11 * * * /bin/touch /root/scripts/test-cron-050508

colucix 05-05-2008 04:50 AM

Did you receive any error message through the root's mail? The crontab user's mailbox is the standard place where output and error of cron jobs are put, if not redirected elsewhere. Or eventually you can try
Code:

0 3 * * * /root/scripts/backup-myserver > /root/cron.log 2>&1
to redirect stdin and stdout to a file. If the cron daemon execute jobs properly, there is no reason for not running a particular job (unless you set the time on 29th february of a non leap year).

billymayday 05-05-2008 05:24 AM

What's in the script? It may be an environment issue

xpucto 05-05-2008 06:25 AM

Solved! Thanks for your help!

As indicated by colucix, I made a redirection to see what the cronjob had to say. In the logs there was the following error message:
Quote:

sudo: sorry, you must have a tty to run sudo
I looked in internet and found out that FC6 made some more restrictions with sudo matters, and that I hat to comment out the line
Quote:

Defaults requiretty
which I did. Now it works.

Thanks again for your help!


All times are GMT -5. The time now is 04:09 PM.