python - 没有 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
解决方案
推荐阅读
- ios - 在 iOS 上使用亚马逊产品广告 API
- sql-server - SQL 数据库的 Azure 用户 GRANT
- python - 在 Python 中构建数据框
- c# - 编辑单元格后重新绑定 DataGridView 的问题
- agda - Agda Vec.filter 给出 Vec≤,我如何回到 Vec?
- vuejs2 - 计算属性返回空数组
- python - Steam Scrapy 问题
- python - 将变量导入另一个 Python + QTDesigner 文件时出错
- c# - 可以通过 EF Core 中的 HTML 添加新的列表条目吗?
- python - 如何更改keras中的图层形状?