Slackware This 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.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-08-2012, 08:06 AM
|
#1
|
|
Member
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: Slackware, Slackware64
Posts: 776
|
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.
Any suggestions?
|
|
|
|
10-08-2012, 08:14 AM
|
#2
|
|
Member
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: Slackware, Slackware64
Posts: 776
Original Poster
|
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.
|
|
|
|
10-08-2012, 09:43 AM
|
#3
|
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,441
|
Something else you can do is, in a root crontab only, use
Code:
00 22 * * * /sbin/init 0
That'll shut down and power off the machine right quick (and clean).
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
Different strokes...
Hope this helps some.
|
|
|
|
10-08-2012, 11:38 AM
|
#4
|
|
Senior Member
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,192
|
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.
|
|
|
|
10-08-2012, 01:24 PM
|
#5
|
|
Senior Member
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 2,441
|
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.
|
|
|
|
10-08-2012, 02:15 PM
|
#6
|
|
Senior Member
Registered: Jul 2007
Distribution: Slackware64-14.0
Posts: 2,192
|
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.
|
|
|
2 members found this post helpful.
|
10-08-2012, 03:58 PM
|
#7
|
|
Member
Registered: Oct 2008
Distribution: Slackware: 12.1, 13.0, 13.1, 13.37, 64-14
Posts: 679
Rep: 
|
Quote:
Originally Posted by T3slider
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!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 06:03 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|