Crond active time prevented the task from executing

[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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值