Your timespec is incorrect. The time specification of a crontab entry consists of 5 fields:
- minute (allowed values: 0-59)
- hour (allowed values: 0-23)
- day of the month (allowed values: 1-31)
- month (allowed values: 1-12)
- weekday (allowed values: 0-7)
The values can be specified as single values (e.g. 4
), or ranges of values (e.g. 2-5
). Multiple values and/or ranges can be specified as comma-separated lists (e.g. 2,4-8,13
). An asterisk (*
) is a shortcut for the full range. Months and weekdays can also be specified by name instead of by number.
By adding /{step}
to a field you can further discriminate the number of executions for the given time field. /2
means run every second time, /5
means run every 5th time, etc. However, you cannot use that discriminator by itself. It must have a time frame to refer to.
If we use the "minute" field as an example, you can specify things like this:
*/5
→ run every 5 minutes (equivalent to 0,5,10,15,20,25,30,35,40,45,50,55
)
0-10/2
→ for the first 10 minutes of the hour run every other minute (equivalent to 0,2,4,6,10
)
Using /1
(step width of 1, i.e. run every time) doesn't make sense, though, as that's already the default. To have your script run every minute you'd simply put an asterisk in the "minute" field:
* * * * * root sh /usr/local/bin/vpn_monitor.sh
* * * * * root bash /usr/local/bin/vpn_monitor.sh
For further information see man 5 crontab
.
As a side-note, setting $SHELL
inside your scripts isn't all that useful. Just specify the desired interpreter in the shebang: #!/bin/sh
for Bourne shell, #!/bin/bash
for Bash. If your shell binaries are not in /bin
, adjust the path accordingly, e.g. #!/usr/local/bin/bash
.