While using VMware’s Photon OS more regularly, some basic activities might be required, one such topic is the creation of cronjobs : creating and managing cronjobs, schedules

Using cronjobs to schedule tasks or operations

You use so called cronjobs in Linux or Photon OS to schedule tasks to automate on a frequent basis. Using cronjobs you can specify the frequent part.

Login using root credentials and open the crontab configuration:

  • crontab -l : list the cronjob details
  • crontab -e : from here you can edit the cronjob details

Using the vi editor, you can add or change the schedule:

1 2 * * *
minute hour day (of the month) month day (of the week)
(month)
(week)

  • any value
    , value list separator
  • range of values
    / step values
    @yearly (non-standard)
    @annually (non-standard)
    @monthly (non-standard)
    @weekly (non-standard)
    @daily (non-standard)
    @hourly (non-standard)
    @reboot (non-standard)

Example:
5 4 * * sun : At 04:05 on Sunday
0 0,12 1 */2 * : At minute 0 past hour 0 and 12 on day-of-month 1 in every 2nd month.
0 4 8-14 * * : At 04:00 on every day-of-month from 8 through 14.

You can find some examples here.
Create queries more easily like these from here.

By default, all cron logs are stored in the main system log which is located in /var/log/syslog on PhotonOS, Ubuntu and Debian systems.
You can filter cron logs in the system log by running the grep command: cat /var/log/syslog | grep cron

By DM

Leave a Reply

Your email address will not be published. Required fields are marked *