Due to some bug in one of my scripts i'm being forced to delete temp files every 30 minutes until i'll figure it out and debug it.
To get it done i've written a small bash script that i run every 30 minutes (tempCleaner)
#!/bin/bash numberOfFiles=$(find -name php* | wc -l) echo "$numberOfFiles" if (("$numberOfFiles" <= "0")) then echo "Nothing to delete" echo "There's nothing to delete, everything is fine $(date)" >> /tmp/scan_log else echo "Something to delete" echo "Oops, there are some files that needs to be deleted $(date)" >> /tmp/scan_log sudo rm -vrf php* >> /tmp/deleted_files_log fi
i've tested it out (./tempCleaner) and it worked just fine now to run it every 30 minutes i'm using cron (sudo crontab -e) and wrote the following: (I'm aware of the time, it's just to test it up rapidly)
* * * * * nice -19 /tmp/tempCleaner >> /tmp/error_log_cron
no matter what i've tried, it's not working for me. why ? what am i doing wrong ? what am i missing ?
Some technical information, The server load is oftenly over 1.0 (not sure if it matters to cron or not) the files are located in /tmp, the files that i want to delete are related to the following group www-data:www-data the bash file (tempCleaner) is set +x and is related to ubuntu:ubuntu