Boot Auto Start service
Centos7:systemctl is-enabled "ServiceName"
Systemctl Enabled "ServiceName" (set to boot)
Centos6:chkconfig--list "ServiceName"
Chkconfig--add "ServiceName" (1 set to boot)
Chkconfig "ServiceName" on (2 set to boot)
Scheduled Tasks
AT:ATD Service for one-time scheduled tasks
At [option] Time (by default all standard outputs are not displayed, and execution results are sent by mail)
Recommendation: If the script is to be executed in a scheduled task, enter the execution result into the/dev/null, or it will generate a large amount of junk e-mail
At "Time" Wall 10:00am (10:00 broadcast 10:00 to ctrl-d save exit)
There are scheduled tasks under/var/spool/at.
-L View Scheduled Tasks
-C "Task number": Displays detailed task information
-D "task number" or ATRM "task number": Delete the specified task number
-V View Current ATD service version
Because at is an interactive program, you can use redirect input when you need a script to create a scheduled task: at <<eof, and then enter the specified content
-F "FileName" input file contents to at
-M when the scheduled task is completed determine whether it is successful
Time: Define when to do at this task
HH:MM[YYYY-MM-DD] defined month Day
Noon,midnight,teatime (4pm)
Tomorrow
Now+#{min,hours,days,weeks}
At Now+20min (20 minutes after execution, 20 minutes after the integer time, other time similar to this)
Whitelist: At.allow (default does not exist)
Blacklist: At.deny (default exists)
If you want the normal user to not be able to execute at, edit the/etc/at.deny, and the user who will restrict it to this file
If a user is in At.deny and At.allow (white list), it is allowed to execute
When a whitelist at.allow this file, it means that all ordinary users who are not in the At.allow file are denied
If there is no whitelist and no blacklist, then ordinary users do not have permission to execute at
Recurring Scheduled Task cron
/var/spool/cron the scheduled tasks created in the store
Cron logs are stored in the/var/log/cron.
The Crond service relies on a Cronie (main package) package, provides Crond services, contains Crond services, and configuration files
Cronie-anacron Auxiliary Package, RPM-QL Cronie-anacron, lists a list of directories where/etc/anacrontab is a configuration file
/etc/cron.daily storing tasks performed on a daily basis
Crontab is a very important configuration file for a scheduled task
System Planning tasks:/etc/crontab
Minute hour Sun and Moon Week (0 or 7 means Sunday)
*/10 * * * * "username" "EXEC command" (executed every 10 minutes)
The number of the month and the day of the week there is a default or relationship
Execute after @reboot reboot
@yearly 0 0 1 1 * (every January 1 0:0)
@annually 0 0 1 1 * (performed on January 1 0:0)
@monthly 0 0 1 * * (1th per month, 0:0)
@weekly 0 0 * 0 (every Sunday 0:0)
@daily 0 0 * * * (0:0 per day)
@hourly 0 * * * * (full execution per hour)
* * * * * (per minute execution)
In a scheduled task, the% symbol has a special meaning
/etc/cron.d/can hold a series of scheduled task files
Centos6:/etc/cron.daily/tmpwatch used to periodically clear temporary files.
Centos7:systemctl Status Systemd-tmpfiles-setup (view program status to clear temporary files)
User Scheduled Tasks:
CRONTAB-E (normal user to create a scheduled task, the default is to open the VI program, no color, edit the variable export Editor=vim can be)
Crontab-l (View scheduled Tasks)
Crontab-l-U ' username ' view scheduled tasks for a specified user
Crontab-r-U ' username ' removes scheduled tasks for a specified user
Crontab-i-R appears whether to delete the prompt message
To control user execution of Scheduled tasks:
/etc/cron. {Allow,deny}
Sleep can be implemented every few seconds
Sleep 10;command (executed every 10s)
Linux Scheduled Tasks