【发布时间】:2021-09-26 15:21:59
【问题描述】:
如何在每行的最后一个井号标记之后按字母顺序对crontab -l 进行排序?
* * * * * curl -m 10 https://google.com # C comment
# * * * * * curl -m 10 https://google.com # A comment
* * * * * curl -m 10 https://google.com # D comment
* * * * * curl -m 10 https://google.com # E comment
* * * * * curl -m 10 https://google.com # Z comment
## * * * * * curl -m 10 https://google.com # B comment
【问题讨论】:
-
为什么?
cron当然不在乎。除非你是强迫症,否则这看起来很愚蠢。 -
因为我有数百个 cron 作业。我使用 python-crontab 以编程方式创建作业,使它们没有特定的顺序。按评论排序是按名称对它们进行分组,以便其他人阅读。这实际上不会对 cron 进行排序,只是对我进行版本控制的输出列表进行排序。