The maximum time unit of a scheduled task is month
1. System delay task
at 23:37 ##Set task execution time
at>rm -fr /mnt/*
Use ctrl +d to end the at interface and initiate a task action
at -l ##View task queue
at -r task number##Cancel task
at -c ## View task content
at now+1min ##Execute
echo hello westos
as the command in 1 minute When there is output, it will be sent to the current user in the form of an email.
Experimental conditions:
Need to build a software warehouse.
Download the software
postfixx.x86_64 mailfixx.x86_64 to
open the mail service
at command: all users of the system can execute it.
Restrict users who execute the at command. The
whitelist has high priority.
man 5 at.deny
Blacklist directory: /etc/at.deny
Whitelist: /etc/at.allow does not exist by default in the system.
Note: After the whitelist is created, all ordinary users cannot execute the at command, and only whitelist users can execute at
Demo:
When there is linux in the user blacklist, the
blacklist still exists.
Note: It is unrealistic to manage the permissions of the root user!
Timed tasks of the system
Experiment premise
Service name:
Experiment
min hour day mouth week
@ @ @ @ @ ##Every minute
@/2 @ @ @ @ ##Every two minutes
@/2 09-17 @ @ @ ##早7到晚5 Every two minutes
@/2 09 -17 3,5 1 5 ## The 3rd and 5th of January or the 5th every two minutes
Note: @ represents*
Storage directory: /var/spool/cron/
/user name
crontab command
-e ##Set-
l ##List tasks-
r ##Delete tasks-
u ##Specify users
Note: Only super users can initiate Specify the user.
User blacklist directory: /etc/cron.deny
User whitelist directory: /etc/cron.allow
Note: Super users are not restricted. When the
whitelist exists, the blacklist will not be read by default
2. System-level crontab
directory: /etc/cron.d/
root user to set
crontab -l (cannot view system-level crontab)
Demonstration: Ensure the purity of the experimental environment
Turn off the whitelist and blacklist
Temporary file cleaning
Temporary files of systemd-tmpfiles can be deleted after the set life cycle ends.
/lib/tmpfiles.d/westos.conf
d /mnt/westos 1777 root root 5s
/usr/lib and /lib are
deleted by a user : The deletion method is to delete the absolute path of the temporary file