bash - crontab - 从 bash 脚本创建的编辑
问题描述
我已经在我能想到的所有地方寻找答案,要么我在错误的地方寻找,要么没有人试图从脚本输入 cron 作业。
我有两个 cron 作业(如下),我想检查或设置并从另一个主 bash 脚本运行。主 bash 脚本执行 cron 作业条目(无需手动输入)。它们在这里(调整了路径以便于查看):
if ! crontab -l | grep "@reboot /home/john/this_script.sh > /home/john/this_script_log.txt 2>&1"; then
(crontab -l ; echo "@reboot /home/john/this_script.sh > /home/john/this_script_log.txt 2>&1") | crontab -
和
if ! crontab -l | grep "/home/john/that_script.sh > /home/john/that_script_log.txt 2>&1"; then
(crontab -l ; echo "* * * * * /home/john/that_script.sh > /home/john/that_script_log.txt 2>&1") | crontab -
fi
权限已设置并经过测试。所以他们都跑了。
我不想crontab -e
用来调整或输入任何上述 cron 作业(因此管道到crontab -
)。据我所知,上面的 if 语句检查 cron 作业是否已经存在,如果不存在,则进入它。
挑战是我错误地在其中一个上走错了路。发现错误后,我尝试对其进行编辑。
我用过crontab -e
,没找到。
crontab -l
它没有出现。
有谁知道如何查找和编辑上面输入的任何脚本(crontab -
)crontabs?
谢谢你
解决方案
推荐阅读
- javascript - 如何在 GAS 中获取一列二维数组?
- javascript - 如何仅将 JSON 文件中的特定属性解析为数组
- haskell - 将 foldl 表达式转换为 foldr 以获得有限列表
- visual-studio - 如何实现 C++/CLI 启动画面?
- firebase - 如何限制和排序 Firestore 中的文档 ID?
- python - 如何修复 ToDoList 不在 Django 的 main.models 中
- image - 有没有办法同时使用图像和文本数据进行精确图像检测TensorFlow
- python - 如何创建一个空的数据框或 numpy 数组,然后将数据添加到其中,作为两列?
- javascript - vue中如何动态显示图片
- keymapping - 在 Ubuntu 中使用 APL 符号,仅限控制台