How to cron a computer restart ?

How to cron a computer restart ?

Post by Matthieu Gaille » Fri, 25 Jun 2004 22:06:08



Hello all,

I'm quite new to Unix. I'd like to schedule a computer restart one time a
month. Don't flame me ! Yes, I *know*  it *is* B A D :-)

I understood how the cron and crontab functions, but everytime I put the
'init' or the 'shutdown' command into the crontab file, I get a mail
claiming that the "command is not found" !

I guess that it is due to the fact that cron doesn't launch the commands as
superuser, though I cron the command from the console...

What can I do ?

Thanks for helping

Matt, Brussels, Belgium

 
 
 

How to cron a computer restart ?

Post by Alexis Huxle » Fri, 25 Jun 2004 23:09:34


Quote:> I'm quite new to Unix. I'd like to schedule a computer restart one time a
> month. Don't flame me ! Yes, I *know*  it *is* B A D :-)

Is it bad? Most places I have worked have done automated reboots once
per week or even once per day, in the early hours.

Quote:> I understood how the cron and crontab functions, but everytime I put the
> 'init' or the 'shutdown' command into the crontab file, I get a mail
> claiming that the "command is not found" !

Because cron runs programs with a very reduced set of directories in the
PATH environment variable, making it unable to find stuff.

On the command line run:

        which shutdown

to determine the full path of shutdown (probably /sbin/shutdown or similar)
and then call shutdown using that full path from the crontab. E.g.:

        0 0 * * 0               /sbin/shutdown -r -y now

Alexis

 
 
 

How to cron a computer restart ?

Post by Matthieu Gaille » Sat, 26 Jun 2004 18:27:30


Quote:> > I'm quite new to Unix. I'd like to schedule a computer restart one time
a
> > month. Don't flame me ! Yes, I *know*  it *is* B A D :-)

> Is it bad? Most places I have worked have done automated reboots once
> per week or even once per day, in the early hours.

Waw - I think one would say that they should debug their programs. Something
that, in this case, I don't have the chance to do.

Quote:

> > I understood how the cron and crontab functions, but everytime I put the
> > 'init' or the 'shutdown' command into the crontab file, I get a mail
> > claiming that the "command is not found" !

> Because cron runs programs with a very reduced set of directories in the
> PATH environment variable, making it unable to find stuff.
> 0 0 * * 0 /sbin/shutdown -r -y now

Thank you very much Alexis, I'm gonna try this. If you don't hear anything
from me it means that it's solved ! I love the newsgroups !

Matthieu