LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cronjob..... (http://www.linuxquestions.org/questions/linux-newbie-8/cronjob-806065/)

milindpk 05-05-2010 07:29 AM

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

PMP 05-05-2010 07:40 AM

Your cronjob entry Please !!
And which user's crontab is it.

RobertP 05-05-2010 08:03 AM

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.

milindpk 05-06-2010 02:57 AM

linux crobjob....
 
Quote:

Originally Posted by PMP (Post 3957949)
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

PMP 05-06-2010 04:41 AM

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).

Randeep 05-06-2010 02:25 PM

here is a nice help on cron.

http://helpinlinux.blogspot.com/2010...sing-cron.html

chrism01 05-06-2010 07:52 PM

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.


All times are GMT -5. The time now is 03:27 PM.