linux 自动关机
来源:互联网 发布:linux清空arp表 编辑:程序博客网 时间:2024/04/30 17:26
原文链接http://www.cnblogs.com/deeryao/archive/2010/09/10/1823665.html
一、shutdown命令关机
各参数功能:
-c 取消前一个shutdown命令。
-f 重新启动时不执行fsck(注:fsck是Linux下的一个检查和修复文件系统的程序)。
-F 重新启动时执行fsck。 -h 将系统关机,在某种程度上功能与halt命令相当。
-k 只是送出信息给所有用户,但并不会真正关机。
-n 不调用init程序关机,而是由shutdown自己进行(一般关机程序是由shutdown调用init来实现关机动作),使用此参数将加快关机速度,但是不建议用户使用此种关机方式。
-r 关机之后重新启动系统。
now 表示立即执行,now=+0
-f<秒数> 送出警告信息和关机信号之间要延迟多少秒。警告信息将提醒用户保存当前进行的工作。
[时间] 设置多久时间后执行shutdown命令。时间参数有hh:mm或+m两种模式。hh:mm格式表示在几点几分执行shutdown命令。例如“shutdown 10:45”表示将在10:45执行shutdown。+m表示m分钟后执行shutdown。比较特别的用法是以now表示立即执行shutdown。值得注意的是这部分参数不能省略。
1、定时关机sudo shutdown -h 23:00 //表示在23点定时关机
2、延时关机sudo shutdown +minutes(这个加号不可省略,minutes表示分钟)比如: sudo shutdown -h +120 //两小时候关机
3、取消前一个关机命令按“Ctrl+C”键或输入命令:shutdown -c
二、编写脚本文件关机
1、先用nano编辑器建立一个文件,如guanji.sh
sudo nano guanji.sh输入如下内容:
#! /bin/shshutdown -h 23:00 //表示晚上23点00分关机,并关闭电源。
2、给脚本可执行权限右键此文件,选择属性->权限,最下方会有一个“允许以程序执行文件”,将这一项勾选,就可以了。
或在命令行下附予权限:
chmod 777 test.sh或: chmod +x test.sh
3、执行脚本命令或双击运行。 #sh guanji.sh
shutdown(8) shutdown(8)
NAME
shutdown - bring the system down
SYNOPSIS
shutdown [OPTION]... TIME [MESSAGE]
DESCRIPTION
shutdown arranges for the system to be brought down in a safe way. All
logged-in users are notified that the system is going down and, within
the last five minutes of TIME, new logins are prevented.
TIME may have different formats, the most common is simply the word
’now’ which will bring the system down immediately. Other valid for-
mats are +m, where m is the number of minutes to wait until shutting
down and hh:mm which specifies the time on the 24hr clock.
Once TIME has elapsed, shutdown sends a request to the init(8) daemon
to bring the system down into the appropriate runlevel.
This is performed by emitting the runlevel(7) event, which includes the
new runlevel in the RUNLEVEL environment variable as well as the previ-
ous runlevel (obtained from the environment or from /var/run/utmp) in
the PREVLEVEL variable. An additional INIT_HALT variable may be set,
this will contain the value HALT when bringing the system down for halt
and POWEROFF when bringing the system down for power off.
OPTIONS
-r Requests that the system be rebooted after it has been brought
down.
-h Requests that the system be either halted or powered off after
it has been brought down, with the choice as to which left up to
the system.
-H Requests that the system be halted after it has been brought
down.
-P Requests that the system be powered off after it has been
brought down.
-c Cancels a running shutdown. TIME is not specified with this
option, the first argument is MESSAGE.
-k Only send out the warning messages and disable logins, do not
actually bring the system down.
ENVIRONMENT
RUNLEVEL
shutdown will read the current runlevel from this environment
variable if set in preference to reading from /var/run/utmp
FILES
/var/run/utmp
Where the current runlevel will be read from; this file will
also be updated with the new runlevel.
/var/log/wtmp
A new runlevel record will be appended to this file for the new
runlevel.
NOTES
The Upstart init(8) daemon does not keep track of runlevels itself,
instead they are implemented entirely by its userspace tools.
See runlevel(7) for more details.
AUTHOR
Written by Scott James Remnant <scott@netsplit.com>
REPORTING BUGS
Report bugs at <https://launchpad.net/upstart/+bugs>
COPYRIGHT
Copyright © 2009 Canonical Ltd.
This is free software; see the source for copying conditions. There is
NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
SEE ALSO
runlevel(7) init(8) telinit(8) reboot(8)
Upstart
- linux自动关机
- linux 自动关机
- linux 自动关机 计划任务
- 完成任务自动关机 linux shell 脚本
- 自动关机
- 自动关机
- 自动关机
- 自动关机
- 自动关机
- 自动关机
- 自动关机
- linux中shutdown命令实现定时自动关机
- Linux中Shutdown命令实现定时自动关机
- Linux中Shutdown命令实现定时自动关机
- linux 系统如何自动关机和开机
- linux 系统如何自动关机和开机
- WinXP自动关机
- 自动关机程序
- poj2689 Prime Distance 有难度 埃拉托斯尼斯筛法的运用
- EFCodeFirst安装失败(包括EntityFrameWork安装),这样解决。。。
- SQL_TRACE及 Tkprof用法以及问题分析
- IOS越狱开发(三)------DEB生成和apt建立
- Ubuntu Install The Eclipse
- linux 自动关机
- spring 注入方式二:注解
- java类库的阅读笔记_jdk1.7.0_40_java.util.concurrent.locks.AbstractQueuedSynchronizer
- pthread与类
- Lanczos Algorithm and it's Parallelization Stragegy翻译
- oracle中用户锁定及解锁
- 已经实习的盆友们,爆料一下实习工资吧,我惨不忍睹啊!
- 【codeforce】A. Group of Students
- cocos2d-x精灵内存管理