Yes you can set up a cron job for it. Try this, it'll be executed at 4am every day. It deletes all log files older than 30 days. Standard output (if any) will be saved to find_out.txt, errors (if any) will be saved to find_err.txt.
Code:
EDITOR=/bin/nano
crontab -e
0 4 * * * find ~ -mtime +30 -name *.log -type f -exec rm {} \; > ~/find_out.txt 2> ~/find_err.txt
- Replace with the editor with one of your choice, nano might not even be installed on your system.
- If ~ for the home directory doesn't work, try $HOME instead. Or use the full path, e.g. /home/sniper instead of ~.
- You might need to add the path to find, so /usr/bin/find instead of find.
__________________