Issue with “date” command in MacOS Mojave

cronmojave

I think this is a "Full Disk Access" problem.

I have added "Terminal" and "cron" to Full Disk Access.

The problem is when I am trying to use the command below, it works from Terminal but not with cron.

cp -n LastSession.plist  /XYZ/LastSession.plist.$(date +%F).txt

It breaks in cron when I add $(date +%F). I tried researching this but no luck.

How can I get this command to run in cron using Mojave?

Best Answer

Figured it out.

You have to escape the % in cron, so should read like this:

* * * * * cp -n LastSession.plist  /XYZ/LastSession.plist.$(date +\%F).txt