On various systems that I administer, there are cron scripts that get run via the commonly-used /etc/cron.{hourly,daily,weekly}
layout. What I want to know is whether there's any common 'disable this script' functionality.
Obviously, simply deleting something out of a given directory will disable it, but I'm looking for a more permanent solution. Deleting /etc/cron.daily/slocate
will work to disable the nightly updatedb
on my home machine (where I never use slocate
), but next time I upgrade the slocate package, I'm pretty sure it'll reappear.
The two distributions I'm most interested in are Gentoo and OpenSUSE, but I'm hoping there's a widely-implemented mechanism. Both distros as I have them use vixie-cron (not sure it matters).
You should be able to
chmod -x scriptname
to disable a script but leave the file in place.run-parts does not execute jobs which have a dot in their name, so
will do the trick.
Usually
cron.daily
is invoked via/etc/crontab
through a line like e.g.run-parts --report /etc/cron.daily
man run-parts
gives you the options.run-parts --test /etc/cron.daily
shows which jobs are executed without running them.I prefer to make a subdir 'Disabled' and move my jobs there.
In any case if you update a package it is likely that the job gets into place again or that removed 'x' bits get restored
You can remove slocate package if you never use it.
If you use cfengine (https://cfengine.com/) you could do this with disable. You just write a promise file for a group of hosts and it will apply itself in the next cfagent run. Doing this with puppet or chef or whatever should also be quite simple.
The /etc/cron.daily et. al. scripts are run by a script called run-parts. That script varies. For example the --test switch mentioned above isn't on the machine I'm using at this instant.
Run-parts is a bash script. It a generally useful tool for running all the scripts in the directory it's given as an argument. It usually found at /usr/bin/run-parts.
It has a tangle of logic for deciding what to run. That code holds the answer to your question, but it varies too. So you need to read the code to be safe.
In the version I'm looking at it has logic that, when working on directory <foo>, checks for <foo>/jobs.deny. If that exists it declines to run any script that is mentioned in that file on a line, alone. Assuming you have this functionality it's awesome because it will keep working when the package that installs is installed or upgraded.
If dealing with RHEL and derivates (which provides the
crontabs
package), you can explicitly disable a job by putting its name into thejobs.deny
file.From crontabs / run-parts man page:
If you don't want the user-crontabs either, just disable crond in your service-list.
In Debian and versions based on Debian this is simply a matter of removing the symlink from the appropriate /etc/rcX.d (for runlevel X).
I don't know how you handle services in SUSE or Gentoo.