In the root users crontab on a Centos 7 server I have the following:
30 4 1-7 * * test $(date +\%u) -eq 7 && /usr/bin/needs-restarting -r || /usr/sbin/shutdown -r
It should run every day at 4:30 between the 1st and 7th day of the month, then it tests if the day of the week is Sunday and only then execute the next command to check if a reboot is required, and then reboot if it is. However my server rebooted today (1st Aug 2017) which is a Tuesday. Can anyone explain why?
30 4 1-7 * */8 /usr/bin/needs-restarting ...