|SokenDev af17953a01||8 months ago|
|README.md||8 months ago|
How to perform a command at a set time each day / hour/ otherwise.
This tutorial will cover how to perform a single command at a set time on a repeat schedule. If you want to restart something automatically, you need to be able to do so with a single command. This tutorial will not acknowledge the existence of any permission-related issues, they are your own problem to ensure they're correct.
You can either start a process, store it's PID, and kill it, or you can use a service manager such as Systemd.
#!/bin/bash systemctl restart myservice
Cronjobs support 4 operators:
*/2= every second minute/month/etc,
*/3= every third minute/month/etc.
Cronjobs are a single line each, following this syntax:
minute hour day month dayofweek /path/to/command.sh output
Their possible values are:
command.shevery 30 minutes:
30 * * * * /path/to/command.sh
command.shat 5am each day:
0 5 * * * /path/to/command.sh
command.shat 1st Thursday of each month, at 7:15pm:
15 19 * * 4 /path/to/command.sh