LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat
User Name
Password
Red Hat This forum is for the discussion of Red Hat Linux.

Notices


Reply
  Search this Thread
Old 08-08-2008, 05:30 AM   #1
ankitsagwekar
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Rep: Reputation: 0
Question can not run cron


i m nood last week install rhel 5.2
i want to know how to use crontab so i do this
crontab -e (from root )

type
Quote:
5 * * * * date
but i not get display of date after 5min

Last edited by ankitsagwekar; 08-08-2008 at 05:31 AM.
 
Old 08-08-2008, 05:57 AM   #2
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
Where do you expect it is displayed? Crontab does not allocate a pseudo-terminal and all the standard output and standard error is sent to the system mail by default, unless you explicitly redirect them to a file (or to /dev/null). Check the root's mail: most likely you have tons of mails with the standard output from the cron jobs.
 
Old 08-08-2008, 06:02 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Quote:
Originally Posted by ankitsagwekar View Post
i want to know how to use crontab so i do this crontab -e (from root )
And if you want to test out stuff, next time please use your personal unprivileged account for that, unless you know the test requires root rights.
 
Old 08-08-2008, 06:27 AM   #4
arava_sandeep
LQ Newbie
 
Registered: Jul 2008
Posts: 3

Rep: Reputation: 0
Angry problem cron not working

Quote:
Originally Posted by ankitsagwekar View Post
i m nood last week install rhel 5.2
i want to know how to use crontab so i do this
crontab -e (from root )

type

but i not get display of date after 5min
hi
i got ur problem
that ur testing cron
u may miss chkconfig crond on and service crond restart
if still problem verfy the ancron
 
Old 08-08-2008, 07:10 AM   #5
ankitsagwekar
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
i check root mail by typing

Quote:
tail /var/spool/mail/root
but not found any mail ?

i also try
Quote:
2 * * * * date > /date

Last edited by ankitsagwekar; 08-08-2008 at 07:28 AM.
 
Old 08-08-2008, 07:26 AM   #6
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
The correct way to look at mail would be simply
Code:
mail
being logged as root in your case. Anyway, have you tried to redirect the output of the date command to a file, to test if crontab works? Is the cron daemon running?
 
Old 08-08-2008, 07:44 AM   #7
ankitsagwekar
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by colucix View Post
have you tried to redirect the output of the date command to a file, to test if crontab works? Is the cron daemon running?
yes look my second quote on second post
 
Old 08-09-2008, 03:43 PM   #8
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
I re-read your first post and I noticed that you stated
Quote:
but i not get display of date after 5min
well... with your crontab entry most likely you don't get the output after 5 minutes, but at 5 minutes of the next hours, for example at 6:05, 7:05, 8:05 and so on. If you really want to run the cron job every 5 minutes you can use the syntax
Code:
*/5 * * * * date
This is the same as specifying all the 5 minutes steps: 0,5,10,15,20,25,30,35,40,45,50,55. Maybe this is what you were looking for. See man 5 crontab for future reference.
 
Old 08-09-2008, 08:23 PM   #9
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,362

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
Here's a more user-friendly guide: http://www.adminschoice.com/docs/cro...Crontab%20file
 
Old 08-11-2008, 02:27 AM   #10
ankitsagwekar
LQ Newbie
 
Registered: Feb 2007
Posts: 19

Original Poster
Rep: Reputation: 0
thanks

thanks dude u solve my problem

thread is closed now
 
  


Reply

Tags
cron



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
did cron run??? why not??? watcher69b Linux - Server 2 07-03-2008 01:13 AM
nothing seems to run from cron cbannister Linux - Newbie 8 04-08-2008 02:09 PM
How to run my cron command ? Tanc Linux - Newbie 6 05-28-2005 04:58 PM
cron weekly does not run jordanthompson Linux - Software 21 01-16-2005 09:52 AM
trying to get cron to run naijaguy Linux - General 12 08-18-2004 05:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Red Hat

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