Getting bad minute error from crontab despite seemingly accurate syntax

10/3/2018

Not sure what's going on as this cronjob is pretty straighforward. I want my cronjob to run every 5 minutes. Below is the script (memory.sh) in it's entirety.

Below that is the schedule it's requested to run on via the crontab.

I've replicated the crontab and run crontab memory.sh both under my username and as root, but each time I get the same error:

"/opt/memory.sh":4: bad minute
errors in crontab file, can't install.

memory.sh

#!/bin/bash

now=`date +%Y-%m-%d.%H:%M:%S`

echo "$now" >>/opt/memory.out
ps aux --sort -rss>> /opt/memory.out


echo "$now" >>/opt/memory_free.out
free -m>> /opt/memory_free.out

crontab

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command*
*/5 * * * * /opt/memory.sh

directory

enter image description here

-- NealR
cron
kubernetes-cronjob
linux

1 Answer

10/3/2018

crontab memory.sh installs a new crontab file. memory.sh is not a crontab, it is a script references from the crontab file. You need to pass the crontab file to the crontab command, or edit the existing file using crontab -e to add the line you indicated.

-- Florian Weimer
Source: StackOverflow