How to regularly Shut Down Windows/Linux]

Source: Internet
Author: User

Before going to bed at night, if you want to use your computer to listen to songs and sleep, and you don't want your computer to stay till tomorrow morning, you need to shut down at a certain time. Although many players now come with the Timed Shutdown function, it is more professional to use commands ~~~

[1] Linux Timed Shutdown

1. shutdown command

Parameters:

-C: cancel the previous shutdown command.

-F does not execute fsck upon restart (Note: fsck is a program for checking and repairing the file system in Linux ).

-F: Execute fsck when restarting. -H: Shut down the system. To some extent, the function is equivalent to that of the halt command.

-K only sends information to all users, but does not actually shut down.

-N does not call the INIT program to shut down, but is implemented by shutdown itself (usually shutdown calls init to shut down the program). Using this parameter will speed up shutdown, however, this shutdown method is not recommended.

-R: restart the system after shutdown.

Now indicates immediate execution, now = + 0

-F <seconds> the number of seconds between the sending of the warning message and the Shutdown signal. The warning information reminds you to save the current work.

[Time] How long will the shutdown command be executed. The time parameter can be hh: mm or + M. Hh: Mm indicates the number of minutes when the shutdown command is executed. For example, "shutdown" indicates that shutdown will be executed. + M indicates that shutdown is executed in M minutes. The special usage is to use now to execute shutdown immediately. It is worth noting that this part of the parameter cannot be omitted.

1. Timed Shutdown sudo shutdown-H // indicates Timed Shutdown

2. Delayed shutdown sudo shutdown + minutes (this plus sign cannot be omitted, Minutes indicates minutes) for example: sudo shutdown-H + 120 // shutdown when two hours are in progress

3. Cancel the previous shutdown command and press Ctrl + C or enter the command: shutdown-C.

2. Write a script file to shut down

1. Use the nano editor to create a file, such as guanji. Sh.

Sudo nano guanji. sh:

#! /Bin/shshutdown-H // shutdown at and power off.

2. Right-click the executable permission of the script and select "properties"> "Permissions". At the bottom of the page, you can select "Allow File Execution by program.

Or attach the following permissions to the command line:

Chmod 777 test. Sh or: chmod + X test. Sh
3. Run the script command or double-click it. # Sh guanji. Sh

[2] windows cmd command Timed Shutdown

Shutdown.exe

Windows XP system uses a program named shutdown.exe to complete shutdown (in windows \ SYSTEM). In general, shutdown of XP is implemented by shutdown.exe. shutdown.exe is used when the host is shut down. You can call shutdown.exe to disable the strong line of customs.

 

 

Shutdown.exe in Windows CommandParameter Introduction

Shutdown.exe-a cancel Shutdown

Shutdown.exe-s Shutdown

Shutdown.exe-F forcibly shut down the application.

Shutdown.exe-m \ The computer name controls the remote computer.

Shutdown.exe-I displays the graphical user interface, but must be the first parameter of shutdown.

Shutdown.exe-l log out of the current user.

Shutdown.exe-r shut down and restart.

Shutdown.exe-t time sets shutdown countdown.

Shutdown.exe-c "message content": Enter the message content in the shutdown dialog box (cannot exceed 127 characters ).

In Windows vista, shutdown.exeis enhanced, and shutdown.exe-H is sleep.

Usage example

For example, if your computer is shut down at, you can select start> Run and enter at shutdown-S, the "system shutdown" dialog box appears on the computer. By default, there is a 30-second countdown and you are prompted to save your work. If you want to shut down the server by a time-based method, you can enter “shutdown.exe-s-t 7200 ", which indicates that the server will be shut down automatically after 120 minutes, and" 7200 "indicates 120 minutes.

If you want to cancel the operation, enter "shutdown-a" in the running process ". In addition, enter "shutdown-I" to open the Set automatic shutdown dialog box and set the automatic shutdown.

For Windows, we can copy shutdown.exe to the system directory system32.

Of course, you can also use shutdown and at life together to shutdown at a time, which is more accurate. Format: at Shutdown Time Shutdown option

Instance: at shutdown-s-t 20 is to shut down the host at and countdown to 20 seconds. You must enable the "Task Scheduler" service before using it.

Delphi calls thisCommandIn useswhen shellapi, and in the form of shellexecute(handle,'open', 'shutdown.exe ','-s-t 0', nil, sw_hide), you can call it.

Enable win2003 to automatically restart the server

Method 1: restart the server from two o'clock on Monday to Sunday: AT/every: M, T, W, Th, F, S, su CMD/C shutdown-r-t-60, that is, every day of the week, that is, every day. In this way, the server can be automatically restarted at every day.

Method 2: the first method may cause the server to fail to be restarted. I did not find the specific cause because the scheduled task is automatically started, and I am prompted later that the startup failed. I will not study this reason, and it is useless without the above method. Please use this method. This will definitely work!

Create a text file in the root directory of drive C, input shutdown-r-t 60, save, and rename it as reboot. CMD, then open the scheduled task in the control panel, add the scheduled task, select the file you just created, enter the restart time next, and enter the computer password in the last step. OK, in this way, you can.

Enter the correct user name and password on the right to enable the server automatically! This method is much easier than searching for software with automatic restart on the Internet!

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.