Can't define daily automatic shutdown with crontab
Hi,
I want to define a daily automatic shutdown of all client PCs here, every evening at 10 PM, since more often than not, folks forget to shutdown their PC. I launched crontab -e and then added the following line: Code:
00 22 * * * /sbin/shutdown -h Note: I edited the crontab file a few minutes before 10 PM, don't know if this has any influence. Any suggestions? |
I'll answer this myself, since I just found the solution. I simply forgot to add 'now' as argument to 'shutdown -h'.
Works OK now. |
Something else you can do is, in a root crontab only, use
Code:
00 22 * * * /sbin/init 0 If, for some odd reason or other, you wanted to reboot at some time (I dunno why but people do actually do this sort of thing on a daily basis): Code:
00 22 * * * /sbin/init 6 Hope this helps some. |
Do not use `init` to change runlevels -- use `telinit`. See `man init`. Using `init` may work, but it is poor form. Off-topic since the problem is solved, but I felt I needed to correct an error I see all too often.
|
Quote:
Quote:
|
In many cases (Slackware included) init is a symlink to telinit and init detects the pid being run anyway, so it makes no difference. This was added for convenience, but on other UNIX systems this may not be the case. On some Linux systems using a non-SysV init, init and telinit are two different binaries (though usually init will recognize the erroneous call and pass to telinit anyway). Again, using init may work, but it is poor form, is non-standard, is not guaranteed to remain compatible (though I don't see it changing on Linux), and may not work on other UNIX systems. It is 'poor form' despite working properly, as I stated. You lose nothing by using telinit instead of init.
|
Quote:
|
All times are GMT -5. The time now is 10:43 PM. |