Hi everybody!
I'm posting here because, having a long time surfing the internet I still don't have a solution to my issue.
The script does a backup of a specific directory once a day, deleting the oldest backups if they are more than 31.
The script run perfectly executed from console, but under crond it create correctly the backup but not seems to delete the in-excess backups.
Code:
#!/bin/bash
/usr/bin/tar cfj /root/condivisa_backups/polizze_`/usr/bin/date | /usr/bin/sed s/\ /_/g`.tar.bz2 /mnt/hd/condivisa/GRUPPO\ POLIZZE 2>/dev/null
/usr/bin/ls -lt /root/condivisa_backups/polizze_* | /usr/bin/gawk 'BEGIN { a=0 } { a++; if (a>31) { system("/usr/bin/rm -f "$8); } }'
As you can see, is the second line that seems not be executed at all.
I really don't understand the reason.
Thank you for helping me,
Karimo