LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   cron restart in fedora 11 (https://www.linuxquestions.org/questions/linux-newbie-8/cron-restart-in-fedora-11-a-745283/)

ahmad2080 08-05-2009 08:36 AM

cron restart in fedora 11
 
Hello,

I am trying to schedule a restart every day at 16:00.
some say that I should edit the /etc/crontab file, while others say that I should use the crontab -e command to specify a cron job....

I don't know the difference, what I know is that both did not work with me...

However, I'll list my small script along with the result of ( crontab -l ) and the logs in /var/log/cron...

The script:(It's location /etc/cron.me/restart)
Quote:

#!/bin/bash
shutdown -r now
Quote:

[root@fedora11 bin]# crontab -l
0 16 * * * /etc/cron.me/restart
Quote:

[root@fedora11 bin]# tail /var/log/cron
Aug 4 19:05:54 fedora11 crontab[4248]: (root) BEGIN EDIT (root)
Aug 4 19:06:01 fedora11 crond[4132]: (root) RELOAD (cron/root)
Aug 4 19:06:10 fedora11 crontab[4248]: (root) REPLACE (root)
Aug 4 19:06:10 fedora11 crontab[4248]: (root) END EDIT (root)
Aug 4 19:07:01 fedora11 crond[4132]: (root) RELOAD (cron/root)
Aug 4 19:07:01 fedora11 crond[4132]: (CRON) INFO (running with inotify support)
Aug 4 19:07:01 fedora11 CROND[4260]: (root) CMD (/etc/cron.me/restart )
Aug 4 19:07:03 fedora11 crontab[4266]: (root) BEGIN EDIT (root)
Aug 4 19:07:05 fedora11 crontab[4266]: (root) END EDIT (root)
Aug 4 19:28:18 fedora11 crontab[4342]: (root) LIST (root)

So why doesn't this work?
I've taken all precautions that I know:
-chmod 755 /etc/cron.me/restart
-The shutdown command can be executed by root user only so I checked the group and user owners of /etc/cron.me and /etc/cron.me/restart ... and they are set to root.
- I restart the crond service and reload it.
- I executed the script : /etc/cron.me/restart and it restarted my comp. but it doesn't do the same using cron......!!!!!!

Thanks for ur help..

knudfl 08-05-2009 09:56 AM

'cron' will understand a full path only :

/sbin/shutdown -r now


.....

sigey 08-05-2009 10:23 AM

this URL will be of help http://kbase.redhat.com/faq/docs/DOC-9248

ahmad2080 08-08-2009 04:18 AM

Thanks, that "full path order" solved my problem.


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