[SOLVED] Can't define daily automatic shutdown with crontab
SlackwareThis Forum is for the discussion of Slackware Linux.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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
This seemed to have no effect. I wonder if there's something else to do for the action to take effect.
Note: I edited the crontab file a few minutes before 10 PM, don't know if this has any influence.
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.
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541
Rep:
Quote:
Originally Posted by T3slider
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.
Beg to disagree:
Quote:
/sbin/telinit is linked to /sbin/init. It takes a one-character argument and sig-
nals init to perform the appropriate action. The following arguments serve as
directives to telinit:
0,1,2,3,4,5 or 6
tell init to switch to the specified run level.
a,b,c tell init to process only those /etc/inittab file entries having runlevel
a,b or c.
Q or q tell init to re-examine the /etc/inittab file.
S or s tell init to switch to single user mode.
U or u tell init to re-execute itself (preserving the state). No re-examining of
/etc/inittab file happens. Run level should be one of Ss12345, otherwise
request would be silently ignored.
telinit can also tell init how long it should wait between sending processes the
SIGTERM and SIGKILL signals. The default is 5 seconds, but this can be changed
with the -t sec option.
telinit can be invoked only by users with appropriate privileges.
The init binary checks if it is init or telinit by looking at its process id; the
real init's process id is always 1. From this it follows that instead of calling
telinit one can also just use init instead as a shortcut.
So, for the sake of curiosity, just what poor form are we talking about here? Been shutting down or rebooting Unix and Linux systems with init runlevel for, oh, 35+ years, never had a problem.
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.
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... but it is poor form, is non-standard, is not guaranteed to remain compatible
Thanks for the simple explanation. I always use telinit out of long habit, but would not have known why not to use init if asked - now I do!
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.