Applicable to:
- Plesk for Windows
- Plesk for Linux
Question
Sometimes it is required to change the time of execution Daily Maintenance Task from the default value of ~03:00 AM to another one, for example in order to balance a load on different servers. How to do this?
Answer
Daily Maintanence Task is executed by Cron daemon, and the way it being run may be slightly different on various Linux distributions. Also, on Windows systems, it is run by Task Scheduler. So, the way to change its execution time will vary too. Here are the instructions for different Plesk installations.
The behavior is configured by /etc/crontab
file:
# cat /etc/crontab
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
14 * * * * root cd / && run-parts --report /etc/cron.hourly
9 2 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
15 1 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
33 1 10 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
#
In this case, cron.daily is executed on 02:09 AM every day.
Daily Task script is run by /etc/cron.daily/50plesk-daily
script. To change the time of execution cron.daily jobs, edit /etc/cron.d/dailyjobs
:
CONFIG_TEXT: # Run the daily, weekly, and monthly jobs if cronie-anacron is not installed
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# run-parts
23 3 * * * root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.daily
21 4 * * 0 root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.weekly
58 4 29 * * root [ ! -f /etc/cron.hourly/0anacron ] && run-parts /etc/cron.monthly
In this case, cron.daily task is configured to be run on 3:23 AM.
Note: Cron uses 24 hour time format.
Execution time is configured in /etc/anacrontab by the parameter
START_HOURS_RANGE
:
# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron
# See anacron(8) and anacrontab(5) for details.
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22
#period in days delay in minutes job-identifier command
1 5 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly
Note: the "delay in minutes" column. It means that with a parameter START_HOURS_RANGE= 3 -22 cron.daily scripts will be run on 03:05 AM. As this behavior may appear a bit sophisticated, you may refer to an official documentation of Oracle Linux for details.
Comments
0 comments
Please sign in to leave a comment.