LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-05-2008, 03:37 AM   #1
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 524

Rep: Reputation: 31
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?!
 
Old 05-05-2008, 03:44 AM   #2
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
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.
 
Old 05-05-2008, 04:27 AM   #3
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 524

Original Poster
Rep: Reputation: 31
Quote:
Originally Posted by billymayday View Post
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

Last edited by xpucto; 05-05-2008 at 04:36 AM.
 
Old 05-05-2008, 04:50 AM   #4
colucix
LQ Guru
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,509

Rep: Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983Reputation: 1983
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).
 
Old 05-05-2008, 05:24 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
What's in the script? It may be an environment issue
 
Old 05-05-2008, 06:25 AM   #6
xpucto
Member
 
Registered: Sep 2005
Location: Vienna, Austria
Distribution: Mint 13
Posts: 524

Original Poster
Rep: Reputation: 31
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!
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cronjobs problem segasieu Linux - Server 2 05-01-2008 10:10 PM
Problem with cronjobs..... freakin'me Linux - General 7 02-11-2006 03:08 PM
outdated cronjobs bujecas Linux - Software 6 08-04-2005 10:24 AM
facing problem with cronjobs manojthakkar Linux - General 7 12-09-2003 11:55 PM
is there a way to stop cronjobs mail for certain acticities manojthakkar Linux - General 5 12-08-2003 10:56 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:20 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration