英文:
Is it possible to create my own crontab special string?
问题
计划任务程序包括八个以“@”开头的特殊字符串:@reboot,@yearly等... (man 5 crontab)。我想创建自己的:@five_minutes = */5 * * * *。
但是否有办法在crontab中创建新的特殊字符串?
英文:
The cron daemon includes eight special strings, starting with "@" : @reboot, @yearly etc... (man 5 crontab). And I would like to create my own: @five_minutes = */5 * * * *.
But is there a way to create new special strings in crontab?
答案1
得分: 0
不,语法不允许这样做。
也许你可以为你的格式编写一个简单的解析器,然后从中生成你实际的 crontab。
sed 's%^@five_minutes%*/5 * * * *%' crontab.in | crontab -。
对于这个特定的简单用例,学习正确的语法似乎是一个更简单和更可靠的解决方案。
英文:
No, the syntax does not allow anything like this.
Perhaps you could write a simple parser for your format, and generate your actual crontab from that.
sed 's%^@five_minutes%*/5 * * * *%' crontab.in | crontab -
For this particular simple use case, learning the proper syntax seems like a much simpler and more robust solution.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论