Day Fifth: Linux Scheduled Tasks

Source: Internet
Author: User

Mail command:

Send and receive mail (mua:mail user agent to send and receive mail)

Use the command:

Mail-s ' Subject ' [email protected]

Enter after entering the interactive input interface, after entering the message content. Enter to end the message entry, the message content can be entered redirect to Mail, the command execution results are sent to the user by mail.

At: Perform a task at once.

How to use:

    • at [Opption] ... time

Time Format:


    • Noon,midnight,teatime,tomorrow,now + # (Min,h,days,weeks)

Common options:

    • -L View Job queue, equivalent to ATQ

    • -F reads the configuration file from the file into the queue and puts all the tasks at the at to the file, allowing at to read the file as a running task. Example: At-f/path/to/file

    • -d deletes the specified queue job, which is equivalent to the ATRM command, and can cancel a job that is queued at the at schedule

    • -C View specific contents of the specified job

    • -V You can use the more obvious time format to list the work lists in at.

650) this.width=650; "class=" Size-full wp-image-86 alignleft "src=" 07/image-201607250838.png "alt=" fifth day: Linux scheduled Task "width=" 501 "/>

650) this.width=650; "class=" Size-full wp-image-87 alignleft "src=" 07/image-201607250839.png "alt=" fifth day: Linux scheduled Task "width=" 410 "/>

650) this.width=650; "class=" AlignCenter size-full wp-image-89 "src=" 2016/07/image-201607250841.png "alt=" fifth day: Linux scheduled Task "width=" 960 "/>650" this.width=650; "class=" AlignCenter Size-full wp-image-88 "src=" Http:// "alt=" Day Fifth: Linux scheduled Task "width=" 983 "/>

650) this.width=650; "class=" AlignCenter size-full wp-image-90 "src=" 2016/07/image-201607250845.png "alt=" fifth day: Linux scheduled Task "width=" 863 "/>crontab:

System cron: The system task is implemented by editing the configuration file/etc/crontab.

User cron: Configuration file saved at/var/spool/cron/$USERNAME

How to use:

    • -L: Lists scheduled tasks that have already been defined (essentially viewing the contents of the configuration file)

    • -E: Define scheduled Tasks through the Vim editor and automatically format checks when you save exits

    • -r: Remove all scheduled Task information

    • -I: Two acknowledgements when using the-r option.

Scheduled Task writing format:

# Example of Job definition:
#.----------------Minute (0-59)
# | .-------------Hour (0-23)
# |  | .----------Day of Month (1-31)
# |  |  | .-------month (1-12) OR jan,feb,mar,apr ...
# |  |  |  | .----Day of Week (0-6) (sunday=0 or 7) or Sun,mon,tue,wed,thu,fri,sat
# |  |  |  | |
# * * * * * * USER-NAME (username) command to be executed (command best use absolute path, plus option)

Attach common time Get format: Date +\%y\%m\%d\%h\%m (precision to minutes)


2, every Monday to Saturday 3:20 A.M., run the CP command to archive the/etc/directory, storage location is/BACKUPS/ETC-YYYY-MM-DD;
* * 1-6/usr/bin/cp/etc/backup/etc-$ (date +\%y-\%m-\%d) 2>/val/log/backup_log 1>/dev/null
3, every Sunday 2:30 A.M., run the CP command to backup the/etc/fstab file, the storage location is/BACKUP/FSTAB-YYYY-MM-DD-HH-MM-SS;
2 * * 7/usr/bin/cp/etc/fstab/backup/fstab-$ (date +%y-%m-%d-%h-%m-%s)
4, every night 12 o'clock, get all the lines in the/proc/meminfo file starting with S or M,
Appended to the/statistics/meminfo.txt file, and before the daily message,
To add a similar =============== separation line;
0 0 * * */bin/grep ' ^s\|^m '/proc/meminfo >>/statistics/meminfo.txt; /bin/echo "==========" >>/statistics/meminfo.txt

650) this.width=650; "class=" AlignCenter size-full wp-image-92 "src=" 2016/07/image-201607251314.png "alt=" fifth day: Linux scheduled Task "width=" 862 "/>

This article from "11243775" blog, declined reprint!

Day Fifth: Linux Scheduled Tasks

Related Article

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: 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.