0

I am new to using Crontab to automate some tasks, and was trying to create an empty text file with the date format as the filename in the /app/tmp folder every minute. I am using Ubuntu 22.04 and accessing cron as the root user.

I tried the echo command to create an empty file using the command:

0-59 * * * * /usr/bin/echo '' > /app/tmp/$(date +%Y-%m-%d_%H:%M).txt

I also tried the touch command to do so:

0-59 * * * * /usr/bin/touch /app/tmp/$(date +%Y-%m-%d_%H:%M).txt

Yet the crontab does not create any files.

  • redirect possible error messages to a file, e.g. `/usr/bin/touch /app/tmp/$(date +%Y-%m-%d_%H:%M).txt 2>> /tmp/log` and check this file. – Bodo Jan 27 '23 at 14:14
  • The problem is that `%` is special to `crontab` and needs to be escaped. – tripleee Jan 27 '23 at 17:46

0 Answers0