How does Linux execute commands at a specific time (using at and batch ")

Source: Internet
Author: User

The at command allows you to specify a specific date and time to run a program. For example, I can start playing music on my CDROM at seven o'clock every morning:

 

At 7: 00

Cdplay <Ctrl> <D>

 

In the preceding example, enter "at" in the command line and press Enter. Next, the AT command displays a "at>" prompt. Then, I enter "cdplay" and press Enter. Finally, I hold down <Ctrl> and <D> at the same time to end the input. If I press enter and another "at>" prompt appears, I can enter the programs that I want to run at seven o'clock. Then, enter <Ctrl> <D>. <Ctrl> <D> it is like sending an end match to the current input, indicating that the input is complete. Do not press <Ctrl> <D> twice in a row. Otherwise, the system automatically exits.

 

You can use the following command to list the current tasks in the task scheduling table:

 

At-l

 

You can see the list of programs that are still waiting in the task scheduling table.

 

If you change your mind, you must delete a program from the task scheduling table. Example:

 

Atrm 8

 

This command will delete the program with the command number 8 from the task scheduling table

You can also schedule a program to run at a later time, for example:

 

At 12/31/00

Startx

 

This command will start my X-Windows System on the new millennium night (December 31, 2000, 5 minutes before midnight ).

 

If you cannot run the AT command, check whether the task scheduling service program (ATD) has been loaded (you can use the root user to run ntsysv to load ). If the AT command is valid for the root user but does not work for common users, check whether the file/etc/at. deny exists and check whether the file/etc/at. allow does not exist. This is the default setting for all users to run the AT command. If you want to run the AT command only for the specified user, you can generate the file/etc/at. allow and add the user list to the file.

 

For other options of the AT command, run

 

Man

 

If you want to run a "processor hunger" task in the background when the system load is low, you can use the batch command. For example, I can run setiathome (a data analysis program to help find external Smart Life, SETI ):

 

Batch

At> setiathome <Ctrl> <D>

 

In the above example, I enter batch in the command line and press Enter. At> command prompt, I enter the name of the program to be run in the background. The program tries to run immediately, but it does not run until the system load is less than 0.8. You can check the system load by checking the Virtual File/proc/loadavg:

 

CAT/proc/loadavg

 

After the batch command is complete, the output result will be sent to my mailbox by email.

 

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.