运行 rmmod 的 Cron 作业在重新启动时不执行

运行 rmmod 的 Cron 作业在重新启动时不执行

这是在带有 Debian 11 的 Proxmox VE 7.3 上。我运行了crontab -e,添加@reboot /home/onboot.sh到文件中,保存它,确保 cron 正在运行,systemctl enable cron.service并验证它在启动时运行systemctl status cron.service

● cron.service - Regular background program processing daemon
     Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset: enabled)
     Active: active (running) since Wed 2023-02-08 17:16:52 EST; 11min ago
       Docs: man:cron(8)
   Main PID: 988 (cron)
      Tasks: 1 (limit: 9394)
     Memory: 1.1M
        CPU: 25ms
     CGroup: /system.slice/cron.service
             └─988 /usr/sbin/cron -f

Feb 08 17:16:52 svr systemd[1]: Started Regular background program processing daemon.
Feb 08 17:16:52 svr cron[988]: (CRON) INFO (pidfile fd = 3)
Feb 08 17:16:52 svr cron[988]: (CRON) INFO (Running @reboot jobs)
Feb 08 17:16:52 svr CRON[994]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Feb 08 17:16:52 svr CRON[996]: (root) CMD (sleep 120 /home/onboot.sh)
Feb 08 17:16:52 svr CRON[994]: pam_unix(cron:session): session closed for user root
Feb 08 17:17:01 svr CRON[1063]: pam_unix(cron:session): session opened for user root(uid=0) by (uid=0)
Feb 08 17:17:01 svr CRON[1064]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 08 17:17:01 svr CRON[1063]: pam_unix(cron:session): session closed for user root

onboot.sh文件包含以下内容:

#!/bin/bash

# Remove USB module or interrupt handler conflict with NIC stops qm 100
rmmod ehci_pci
rmmod ehci_hcd

我尝试将脚本文件移动到/home/usr/local/bin/usr/local/sbin,但没有成功。 2次重启后,cron日志显示:

Feb  8 17:08:13 svr cron[985]: (CRON) INFO (pidfile fd = 3)
Feb  8 17:08:13 svr cron[985]: (CRON) INFO (Running @reboot jobs)
Feb  8 17:08:13 svr CRON[993]: (root) CMD (sleep 120 /home/onboot.sh)
Feb  8 17:15:09 svr crontab[2206]: (root) BEGIN EDIT (root)
Feb  8 17:15:34 svr crontab[2206]: (root) END EDIT (root)
Feb  8 17:16:52 svr cron[988]: (CRON) INFO (pidfile fd = 3)
Feb  8 17:16:52 svr cron[988]: (CRON) INFO (Running @reboot jobs)
Feb  8 17:16:52 svr CRON[996]: (root) CMD (sleep 120 /home/onboot.sh)
Feb  8 17:17:01 svr CRON[1064]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)

但仅此而已。如果我像中那样正常运行脚本文件bash /home/onboot.sh,它执行得很好。权限/home/onboot.sh

-rwxr-xr-x 1 root root 150 Feb 8 17:14 /home/onboot.sh

我有什么明显的疏忽吗?

答案1

全部归功于弗雷迪但修复方法是将完整路径添加rmmod到脚本文件中,即/usr/sbin/rmmod ehci_pci

相关内容