0

I am trying to schedule a job using crontab, but it is not giving any output. The same thing I am able to do through a script, and is solving my problem. But I would like to know what mistake I am doing here in crontab due to which it is not working.

17 12 * * * /usr/bin/ls -ltr /home/saad/Desktop/labels/ | /usr/bin/grep _label_of_ | /usr/bin/grep $(date -d '1 day ago' '+%d%m%Y') >> /home/saad/Desktop/log
AdminBee
  • 22,803
  • 2
    why not using a simplier version of it in a - exec parameter of one only find command I guess it wil be less confusing & you will get less restriction on crontab environnement vs a classical shell environnement // otherwise you might make it a script and call the script by the crontab. I mean something looking like find /home/saad/Desktop/labels/ -type d -mtime -1 -exec /usr/bin/grep -E "_label_of_ {} >> /home/saad/Desktop/log \; more or less depending of the exact content & ouptut needed – francois P Jun 22 '23 at 08:49
  • 4
  • 1
    Please provide examples of the filenames you're matching. There is a much easier way to handle this. But the reason it's failing is in the duplicate – Chris Davies Jun 22 '23 at 10:06

0 Answers0