Many of the applications required weekly cron jobs to perform a few tasks. For example, perform weekly maintenance, cleanup disk spaces, cleanup mailing list, and other tasks. You may run your weekly tasks on any day of the week. CPU and memory consumption is required for jobs that require a CPU and memory. Those jobs are best to run on a weekend day.
Scheduling a Cronjob for Sunday.
The day of the week is determined by the fifth section of the cron timer. You can specify a day by using numbers such as 0-7, where 0 and 7 both correspond to Sunday, 1 is Monday, 2 is Tuesday, and so on. We may also refer to the first three letters of the day like sun, mon, etc.
The cron daemon can be configured to run shell scripts at 07:30 AM every Sunday using the following line:
- Define a day in Crontab using numbers:
30 7 * * 0 script.sh
- Define a day in Crontab using numbers:
30 7 * * sun script.sh
You can schedule your weekly cronjob by editing the crontab using “crontab -e” in a text editor.
Scheduing Job with @weekly
Keyword
The @weekly crontab keyword provides for executing tasks every Sunday at 12:00 AM. You may replace the time with @weekly, which saves time. The command will execute at precisely 12:00 AM, and we cannot alter it.
@weekly script.sh
This quick tutorial should help you set up a corn job to run weekly. Please note that you can schedule a job in two-time formats.