Linux中poweroff指令用来关闭计算机操作系统并且切断系统电源。poweroff、reboot和halt可分别用于关机、重启或停止机器。这三个指令都有相同的选项。
poweroff的命令格式,
poweroff [OPTIONS...]
常用选项,
-d, --no-wtmp关闭操作系统时,不将操作写入日志文件“/var/log/wtmp”。-f, --force强制关闭操作系统。-n, --no-sync关闭操作系统前不同步硬盘/存储介质。-w, --wtmp-only不真正关闭操作系统,仅在日志文件“/var/log/wtmp”中写入 wtmp 关闭条目。-p, --poweroff不管调用 poweroff、reboot 和 halt 中的哪一个,都要切断主机电源。--help显示帮助信息。--halt不管调用 poweroff, reboot 和 halt 中的哪一个,都要停止机器。--no-wall请勿在 poweroff, reboot 或 halt 前发送留言。
其中poweroff -p,相当于直接拔电源关机,可以用来模拟某些服务器hang的场景,可以通过man poweroff,了解参数含义,
-p, --poweroffPower-off the machine, regardless of which one of the three commands is invoked.
可能有朋友了解用过shutdown等指令,通过man,可以知道它的某些参数,就相当调用poweroff、halt、reboot,
--helpPrint a short help text and exit.-H, --haltHalt the machine.-P, --poweroffPower-off the machine (the default).-r, --rebootReboot the machine.-hEquivalent to --poweroff, unless --halt is specified.-kDo not halt, power-off, reboot, just write wall message.--no-wallDo not send wall message before halt, power-off, reboot.-cCancel a pending shutdown. This may be used cancel the effect of an invocation of shutdown with a time argument that is not "+0" or "now".
如果您认为这篇文章有些帮助,还请不吝点下文章末尾的"点赞"和"在看",或者直接转发pyq,

文章转载自bisal的个人杂货铺,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




