V
V
vlarkanov2019-04-01 10:00:00
linux
vlarkanov, 2019-04-01 10:00:00

Why is the cron job not running correctly?

I have this line in /etc/crontab:

1 2 * * * 	root	/bin/rmdir /var/spool/asterisk/monitor/$(date +%Y/%m/%d -d "12 day ago")/*

those. every day at 2:01 we delete all empty folders at /var/spool/asterisk/monitor/date-which-was-12-days-ago.
The task is not running. If you run the command in the console - everything is ok. I went to read the syslog for what happens when I try to complete the task - I found this:
Apr  1 02:01:01 ru-mos-dc01-ast01 CRON[23894]: (root) CMD (/bin/rmdir /var/spool/asterisk/monitor/$(date +)

Those. the command was truncated from the % character and beyond. How to fix?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-04-01
@vlarkanov

Put command in shell script, run it from cron

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question