I have a script and configuration file.
- Configuration file contains information about if script will run or not (enabled or disabled).
- If enabled, script must run in predetermined intervals.
I can write a cron job to run script in preset intervals and when script runs I can read the config file and if it is not enabled then I can exit.
However, I'm looking a more convenient way to do this. Is there any way to tell the cron's itself that this job is not activated in boot time? So cron will not start the job if it's not enabled (or the otherwise). Or is it possible to enable/disable job in runtime?
Thanks in advance.
Ah, now I undersand! That's a fairly common request:
All you need is to test for the existence of a given file, not its content. E.g. if you want to run the cron job, create a file say in yr home directory:
$ touch /home/you/cronjob_enable
.Then edit yr user crontab:
That's it. As long as the file is there (empty or not, it's irrelevant) and you have permission to run
/home/linux/test.sh
, the scripttest.sh
will run.When you erase the file
/home/you/cronjob_enable
, the script test.sh will not be executed.