LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 04-26-2011, 02:29 AM   #1
etika
Member
 
Registered: Dec 2010
Posts: 38

Rep: Reputation: 0
Unhappy crontab not working


SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
*/5 * * * * root echo "****************"|mail -s "eeeee" [emailabc@gmail.com[/email]
55 * * * * root cd / && run-parts --report /etc/cron.hourly


what could be the possible reasons of /etc/crontab(systemwide cron) not working
Please help

Last edited by etika; 04-26-2011 at 03:58 AM.
 
Old 04-26-2011, 02:36 AM   #2
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
What doesn't work?
Any pointers in the logfiles, mail from cron to root?
Cron uses a limited path, so try to give the whole path to the commands and files.

Kind regards
 
Old 04-26-2011, 03:34 AM   #3
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
what is this / for in:
*/5
and why do you mention "root" in those lines?

Have a look in http://adminschoice.com/crontab-quick-reference for syntax and examples

Also, how did you get crontab list? did you launch:
crontab -l
 
Old 04-26-2011, 03:45 AM   #4
brownie_cookie
Member
 
Registered: Mar 2011
Location: Belgium
Distribution: CentOS release 5.5 (Final), Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Posts: 416
Blog Entries: 2

Rep: Reputation: 12
Quote:
Originally Posted by etika View Post
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

# m h dom mon dow user command
*/5 * * * * root echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * root cd / && run-parts --report /etc/cron.hourly


what could be the possible reasons of /etc/crontab(systemwide cron) not working
Please help
OFFTOPIC
I would strongly suggest that you hide your e-mailaddress

Last edited by brownie_cookie; 04-26-2011 at 04:55 AM.
 
1 members found this post helpful.
Old 04-26-2011, 04:24 AM   #5
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
Originally Posted by 16pide View Post
what is this / for in:
*/5
Code:
*/5 * * * *
will execute the cron every 5 minutes


Kind regards

Last edited by repo; 04-26-2011 at 04:25 AM.
 
Old 04-27-2011, 02:03 AM   #6
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
I did not know the */5 syntax, but tried it, and it works.
There is still the issue with "root" mentioned on every line, and I'm sure this won't work.

Also, why do you mention the SHELL and PATH variables???
Please remove this from the crontab entries

Here is what I suggest you put in your cron (using crontab -e)

<quote>
5 * * * * echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * cd / && run-parts --report /etc/cron.hourly
*/1 * * * * echo cron-works>/tmp/cron-works.txt
</quote>

you should see a file created in /tmp every minute (check with ls -l)
 
Old 04-27-2011, 02:08 AM   #7
16pide
Member
 
Registered: Jan 2010
Posts: 418

Rep: Reputation: 83
using crontab -e, enter this AND ONLY THIS in your crontab:
Code:
*/5 * * * * echo "****************"|mail -s "eeeee" abc@gmail.com
55 * * * * cd / && run-parts --report /etc/cron.hourly
*/1 * * * * echo cron-works>/tmp/cron-works.txt
After a minute you should see the file /tmp/cron-works.txt be created
And maybe your other cron lines now work because I removed "root" from them
And also, I removed the variables definition you had put at the beginning (I don't think this is crontab syntax.

Anyway, start with exactly this, and if my */1 line works, then you have a model
 
Old 04-27-2011, 04:38 AM   #8
repo
LQ 5k Club
 
Registered: May 2001
Location: Belgium
Distribution: Arch
Posts: 8,529

Rep: Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899Reputation: 899
Quote:
There is still the issue with "root" mentioned on every line, and I'm sure this won't work.
You are correct, linux cron doesn't have a user field.
Gives an error message, but the cron is executed.

Kind regards

Last edited by repo; 04-27-2011 at 05:09 AM.
 
  


Reply



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
Crontab is not working, the script is working arfal SUSE / openSUSE 6 02-08-2010 08:48 PM
crontab not working ankitsagwekar Red Hat 1 08-08-2008 05:45 AM
crontab not working mahmoud Linux - Newbie 16 07-11-2008 12:46 PM
Crontab not working Zeno McDohl Linux - Newbie 1 06-05-2007 06:52 PM
Crontab Not working appropriate? roclok Linux - Software 9 06-15-2006 11:34 PM

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

All times are GMT -5. The time now is 07:21 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