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
  • 21,637
  • 21
  • 47
  • 71
  • 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
    Obligatory: [Why not parse ls?](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead) – Panki Jun 22 '23 at 08:51
  • 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 – roaima Jun 22 '23 at 10:06

0 Answers0