如何在Windows中从cygwin执行shutdown命令

Bha*_*ath 10 cygwin

如何在Windows 2003服务器计算机上从Cygwin执行Windows关闭命令(shutdown -r)?

Fra*_*kie 13

// windows xp
shutdown -s -f now

// windows 7
shutdown /r /t 0
Run Code Online (Sandbox Code Playgroud)

它因Windows版本而异.只需使用检查shutdown --help并找出在特定版本上使用的内容.

在我的案例中从cygwin获取的帮助页面(因各种原因而异).

% shutdown --help
Usage: shutdown [OPTION]... time
Bring the system down.

  -f, --force      Forces the execution.
  -s, --shutdown   The system will shutdown and power off (if supported)
  -r, --reboot     The system will reboot.
  -h, --hibernate  The system will suspend to disk (if supported)
  -p, --suspend    The system will suspend to RAM (if supported)
      --help       Display this help and exit.
      --version    Output version information and exit.

`time' is either the time in seconds or `+' and the time in minutes or a
timestamp in the format `hh:mm' or the word "now" for an immediate action.

To reboot is the default if started as `reboot', to hibernate if started
as `hibernate', to suspend if started as `suspend', to shutdown otherwise.
Run Code Online (Sandbox Code Playgroud)