LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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-2010, 07:29 AM   #1
milindpk
LQ Newbie
 
Registered: May 2010
Posts: 3

Rep: Reputation: 0
Cronjob.....


I am just unable to execute a simple cron job from my fedora machine. I want to halt my machine at a given time every day. Pl. guide me regarding this.

Regards.

Milind
 
Old 05-05-2010, 07:40 AM   #2
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Your cronjob entry Please !!
And which user's crontab is it.
 
Old 05-05-2010, 08:03 AM   #3
RobertP
Member
 
Registered: Jan 2004
Location: Manitoba, Canada
Distribution: Debian
Posts: 453

Rep: Reputation: 32
To set a crontab

crontab -e sets a crontab

crontab -l lists a crontab. Here's one that sets the time hourly

crontab -l
# m h dom mon dow command
37 * * * * /usr/sbin/ntpdate dual

Replace the command with /sbin/shutdown -h now and change the hour and minute field with the time you want to shutdown. If your user has not the privilege of shutting down, you may have to be root to create the entry.
 
Old 05-06-2010, 02:57 AM   #4
milindpk
LQ Newbie
 
Registered: May 2010
Posts: 3

Original Poster
Rep: Reputation: 0
linux crobjob....

Quote:
Originally Posted by PMP View Post
Your cronjob entry Please !!
And which user's crontab is it.
30 21 * * * /root/halt.sh

Through root user I am trying to execute the said cronjob.

Regards.

Milind
 
Old 05-06-2010, 04:41 AM   #5
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
What is there in halt.sh.

Redirect the stdout and STDERR to a log file to see any possible errors

Code:
30 21 * * * /root/halt.sh  1>>/tmp/halt.log 2>>/tmp/halt.err
Now see these logs after your command executes (after 21:30).
 
Old 05-06-2010, 02:25 PM   #6
Randeep
LQ Newbie
 
Registered: Apr 2010
Location: Bangalore
Distribution: Redhat, Centos
Posts: 25

Rep: Reputation: 0
here is a nice help on cron.

http://helpinlinux.blogspot.com/2010...sing-cron.html
 
Old 05-06-2010, 07:52 PM   #7
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.6, Centos 5.10
Posts: 16,324

Rep: Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041Reputation: 2041
Also, cron usually has a minimal env, so the default PATH may not include the cmds you want. Its always advisable in cron jobs to use full paths to all cmds & files used.
As above, show us the script content.
 
  


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
cronjob dnaqvi Linux - General 5 04-26-2010 05:05 AM
cronjob xser Linux - Software 6 07-27-2008 10:38 PM
Cronjob engnet Linux - Networking 6 03-03-2004 10:21 AM
cronjob ugob Linux - Software 0 03-03-2004 10:20 AM
Su in a cronjob michedlp Programming 3 11-06-2003 09:30 AM


All times are GMT -5. The time now is 04:40 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration