[root@mydb ~]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; preset: enabled)
Active: active (running) since Sun 2024-11-03 15:00:49 CST; 3min 10s ago
Main PID: 8260 (crond)
Tasks: 1 (limit: 51199)
Memory: 1.0M
CPU: 189ms
CGroup: /system.slice/crond.service
└─8260 /usr/sbin/crond -n
Here is a crond active time.
Active: active (running) since Sun 2024-11-03 15:00:49
The script to be tested is that the time in crontab -l must be greater than this time, otherwise the script will not run and there will be no information in the log.
For example, setting this will not run.
[root@mydb ~]# crontab -l
0 15 * * * /root/dump.sh > /root/db_backup.log 2>&1 &
[root@mydb ~]# date -s "Sun Nov 3 2:59:55 PM CST 2024"
Sun Nov 3 02:59:55 PM CST 2024
The correct way is to restart the crond service and update the activation time after setting the time.
or
Set the value of time to a value greater than active time.
[root@mydb ~]# date -s "Sun Nov 3 2:59:50 PM CST 2024"
Sun Nov 3 02:59:50 PM CST 2024
[root@mydb ~]# systemctl restart crond
[root@mydb ~]# date
Sun Nov 3 02:59:57 PM CST 2024
[root@mydb ~]# systemctl status crond
● crond.service - Command Scheduler
Loaded: loaded (/usr/lib/systemd/system/crond.service; enabled; preset: enabled)
Active: active (running) since Sun 2024-11-03 14:59:56 CST; 16s ago
Main PID: 8615 (crond)
Tasks: 1 (limit: 51199)
Memory: 968.0K
CPU: 17ms
CGroup: /system.slice/crond.service
└─8615 /usr/sbin/crond -n