与从 cron.* 目录中删除相应的文件相比,禁用 Ubuntu 附带的 cronjob 是否安全(或者是否有更好的方法)?在这种特殊情况下,我想停用 fstrim-stuff,因为我有两个 SSD 的配置(一个三星 850 EVO 和一些金士顿 SSD,它们随我的笔记本一起提供,作为我用所述三星替换的预装 HDD 的缓存) )并希望完全控制哪些内容会被修剪,哪些内容不会......
如果您检查/etc/crontab
,您会发现它用于run-parts
运行每日/每周/等。定时任务(通过anacron
):
$ grep run /etc/anacrontab
1 5 cron.daily run-parts --report /etc/cron.daily
7 10 cron.weekly run-parts --report /etc/cron.weekly
@monthly 15 cron.monthly run-parts --report /etc/cron.monthly
Run Code Online (Sandbox Code Playgroud)
默认情况下:
run-parts runs all the executable files named within constraints
described below, found in directory directory. Other files and
directories are silently ignored.
If neither the --lsbsysinit option nor the --regex option is given then
the names must consist entirely of ASCII upper- and lower-case letters,
ASCII digits, ASCII underscores, and ASCII minus-hyphens.
Run Code Online (Sandbox Code Playgroud)
因此,要禁用给定作业,您可以:
sudo chmod -x /etc/cron.daily/foo
).
或其他角色run-parts
所以:
sudo chmod -x /etc/cron.weekly/fstrim
Run Code Online (Sandbox Code Playgroud)