Enterprise application-On duty, 135 messages a week to the students to clean the health. The script takes advantage of Linux's timed task crontab to run once a day.
1. Turn on the crontab log.
Crontab does not turn on the log by default, so start the log of the scheduled task first to view
Modify the Rsyslog service to delete the #cron. * before the/etc/rsyslog.d/50-default.conf file; Restart the Rsyslog service with service Rsyslog restart:
2. Write timed Tasks
Crontab-e
Start the user's scheduled task, that is, to create a user name as the file name of the scheduled task file, location in/var/spool/cron/crontabs/.
The Schedule Task statement format is: Execution period + command, the period has 5 fields, respectively is
Minutes, hours, days (day of month), months (month of year), weeks (days of week).
Each domain does not limit any words with *, the overall format is:
* * * * * command
Like my script is/home/xiaofeng/cleanroom.py.
Execution Environment for/usr/bin/python3
Run at 9 o ' Day
The statement is
0 9 * * */usr/bin/python3/home/xiaofeng/cleanroom.py
Restart the Cron service after you finish writing
Service Cron Restart
By the way, enclose the usual periodic format
Execute */5 every five minutes * * * * Hourly Execution 0 * * * * daily execution 0 0 * * * Weekly execution 0 0 * * 0 monthly execution 0 0 1 * * yearly Execution
0 0 1 1 *
Linux timed tasks Execute Python script