如何通过脚本创建 crontab [英] How do I create a crontab through a script
本文介绍了如何通过脚本创建 crontab的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要通过我运行的脚本来添加一个 cron 作业来设置服务器.我目前正在使用 Ubuntu.我可以使用 crontab -e
但这将打开一个编辑器来编辑当前的 crontab.我想以编程方式执行此操作.
I need to add a cron job thru a script I run to set up a server. I am currently using Ubuntu. I can use crontab -e
but that will open an editor to edit the current crontab. I want to do this programmatically.
可以吗?
推荐答案
Cron 作业通常存储在 /var/spool/cron
Cron jobs usually are stored in a per-user file under /var/spool/cron
您要做的最简单的事情可能就是创建一个配置了作业的文本文件,然后将其复制到 cron spool 文件夹并确保它具有正确的权限 (600).
The simplest thing for you to do is probably just create a text file with the job configured, then copy it to the cron spool folder and make sure it has the right permissions (600).
这篇关于如何通过脚本创建 crontab的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文