I have question why is my cmd for "removing all files in directory except last 20" not working within cron but in command prompt yes.
* * * * * ls -1tr /home/testusr/test | head -n -20 | xargs -d '\n' rm -f > /var/opt/check.log 2>&1
Directory contains let say 100x files which are named DATA-20140605xxxx generated minute by minute.
Thank advance for any answer.
ls -1tr /home/testusr/test | head -n -20 | xargs -d '\n' rm -fI receive rm: cannot remove `DATA-20140605085900-20140605090000': No such file or directory
– George_223907 Jun 05 '14 at 09:31rmdoesn´t know exact location. – George_223907 Jun 05 '14 at 09:41