Command on crontab not working but If I run the same command on terminal, it works.
[root@ds backup]# crontab -l
* * * * * find /opt/backup -type f -regextype posix-extended -not -regex '.*('$(sed 's/ /|/g' <<<$(echo {6..0} | xargs -I{} -d ' ' date --date={}' days ago' +"%Y%m%d" | xargs echo))').*' &> /home/ocdn_adm/f.txt
#
#
After 2 mins, I run these commands,
[root@ds backup]# cat /home/ocdn_adm/f.txt
cat: /home/ocdn_adm/f.txt: No such file or directory
Seems like cron command fails to run
But If I run the same command on terminal
[root@ds backup]# find /opt/backup -type f -regextype posix-extended -not -regex '.*('$(sed 's/ /|/g' <<<$(echo {6..0} | xargs -I{} -d ' ' date --date={}' days ago' +"%Y%m%d" | xargs echo))').*' &> /home/ocdn_adm/f.txt
[root@ds backup]# cat /home/ocdn_adm/f.txt
/opt/backup/conf-backup-20180407.tar.gz
it works, weired. Can I make the command to work on crontab?
\%Y\%m\%d
but it still fails to work. – Avinash Raj May 11 '18 at 12:19