Will renaming a cron file in /var/spool/cron/ mean that the contents of the cron file will not be executed anymore? Or will all files in /var/spool/cron/ be executed, no matter the name of the file.
feedback
|
|
Files in /var/spool/cron (or /var/spool/cron/crontabs or /var/spool/cron/tabs on some systems) will be run with the permissions of the user for whom the file is named. For instance, /var/spool/cron/root will run as user "root" and /var/spool/cron/tom_13 will run as user "tom_13". If a crontab file is renamed to another valid user, it should run as that user. However, there are two caveats:
Check the manpage for crontab (
| |||
|
feedback
|
|
Cron is tightened to /etc/crontab, where all the magic happens. Actually, by default crontab has only one record similar to this:
As you see, this will execute /usr/lib/cron/run-crons every 15 minutes and run-crons in fact is a script. Taking a brief look at the script you will see what directories should hold cron scripts:
Digging deeper and checking what this script is about you can see that yes, it will execute all the scripts in appropriate directories:
... except mentioned file extensions. So you can simply add a ".bak" add the end of the file so cron will not execute it. NOTE: This post is written using OpenSUSE, and things can vary for other distros | |||||||
feedback
|
|
If you want to prevent it from running, one way would be to edit the crontab for that user and comment out all the lines:
and put a # at the beginning of each line that doesn't have one. | |||
|
feedback
|
|
The man cron says the following:
So if I interpret this correctly, a rename to an unexisting user will do the trick.. | |||
feedback
|