首页 > 解决方案 > 没有 sudo 的 Cron 作业重启

问题描述

有没有办法给用户 crontab 使用重启命令的权限?

我希望 crontab 激活一个使用 geckodriver 的 python 脚本,然后在脚本完成时重新启动设备。当前的问题是 geckodriver 不会以 root 身份运行,并且当脚本尝试使用 reboot 命令时,我的非 root crontab 会给出以下错误:

Failed to set wall message, ignoring: Interactive authentication required. 
Failed to reboot system via logind: Interactive authentication required.
Failed to start reboot.target:Interactive authentication required.
See system logs and 'systemctl status reboot.target' for details.

如果无法授予非 root cron 作业重新启动的权限,是否有其他方便的方法来规避该问题?我想一个解决方案可能是将脚本的重启部分作为第二个脚本分开,并将其包含在根 crontab 中,以便在第一个脚本之后运行。

我正在使用 Ubuntu 18.10

标签: pythoncrongeckodriver

解决方案


推荐阅读