Sunday, January 6, 2013

Differences between Linux shutdown commands?

Q. Can somebody please explain the differences between these commands?

> sync; sync; halt
> shutdown -h now
> init 0

A. sync is to synchronize data on disk with memory. When you write something onto disk it doesn't necessarily mean that the data is written at the same time when u initiate the command. The data to be written would be cached in memory and will be written onto the disk on a later time. For AIX the delay is 1 minute, not sure for linux.

Use sync command to write all the data onto the disk that are waiting to be written.

And there are not much differences between shutdown and int 0 as shutdown will internally call int which intern execute init scripts to shutdown all the applications that has an init stop script [/etc/rc(x).d] and the system will be brought down gracefully. The reboot/halt command do not call application stop scripts and there can be a data loss. My recommendation is to use

#shutdown or
#telinit 0 (use telinit on linux to call an init level. eg, telinit 6 instead of init 6)

Linux based code, simple shutdown command?
Q. I want to write a simple shutdown code for my linux based pc, in dos its shutdown -s -t (seconds). What is it in linux?
Not the reboot command, actually shuting it down.
shutdown -a -t 30

A. shutdown [-a][-t sec][-krhnfFc][time][warning-message]
=
-a Use /etc/shutdown.allow.
-t sec Tell init to wait sec seconds between sending processes the warning and the kill signal, before changing to another runlevel.
-k Don't really shutdown; only send the warning messages to everybody.
-r Reboot after shutdown.
-h Halt after shutdown.
-n Don't call init to do the shutdown but do it ourselves. The use of this option is discouraged, and its results are not always what you'd expect.
-f Skip fsck on reboot.
-F Force fsck on reboot.
-c Cancel an already running shutdown. With this option it is of course not possible to give the time argument, but you can enter an explanatory message on the command line that will be sent to all users.
time When to shutdown.
warning-message Message to send to all users.
=====
Examples

shutdown 8:00
Shutdown the computer at 8-oclock

Related commands

halt
poweroff
reboot

On Linux, how do I have a command run on shutdown?
Q. On Linux, I want a few commands run when it does a shutdown. I know on boot up you can place commands/scripts in /etc/rc.local, how do I do run a command/script upon shutdown? Thanks!

A. Check this website



http://www.querycat.com/question/7bcbe217389e1b57a62d65e6807056bf




Powered by Yahoo! Answers

No comments:

Post a Comment