I need some help with a bash
script.
The script "backup.sh" looks like this:
rm -f $(ls -t /backups/mongo/ | awk 'NR>14')
rsync -pvztr --progress /backups/*...........
I want to remove old files in /backups/mongo/ folder, keeping no more than 15 files. The script works fine if I run ./backup.sh, but if I make it run as a cronjob, the remove part (rm) does not work, the rests work.
Can someone help me spot the problem?
Looks like you have to load bash profile. Its not loading by default when you call bash script from crontab. Just add
to the beginning of you script