Cron Job to move files not running
I added this command in my crontab, but it's not working. I saved in both my user and root crontab but neither is working.
* * * * * [ $(ls -al /media/cyper/evo_1tb | grep plot | wc -l) -gt 0 ] && [ $(ps aux | grep mv | grep -v grep | wc -l) -eq 0 ] && mv /media/cyper/evo_1tb/*.plot /media/cyper/Farm5
grep CRON /var/log/syslog
shows it is being executed, but no files are being copied.
May 22 23:53:01 Plotter CRON[1010104]: (root) CMD ([ $(ls -al /media/cyper/evo_1tb | grep plot | wc -l) -gt 0 ] && [ $(ps aux | grep mv | grep -v grep | wc -l) -eq 0 ] && mv /media/cyper/evo_1tb/*.plot /media/cyper/Farm5)
May 22 23:53:01 Plotter CRON[1010105]: (cyper) CMD ([ $(ls -al /media/cyper/evo_1tb | grep plot | wc -l) -gt 0 ] && [ $(ps aux | grep mv | grep -v grep | wc -l) -eq 0 ] && mv /media/cyper/evo_1tb/*.plot /media/cyper/Farm5)
There is no copy command in your crontab. Did you mean "moved"? Don't make your crontab commandline too complex, create a script that does the dirty work and let cron start that script.
If this command does run for other users too, this one may detect a running "mv" from one of those, and decide not to run itself.