I have 3 users on my server, 2 of them are for FTP uploads.
I want CRON to fire a job every once in a while that deletes files in a folder called 'subdomain' in their respective home dir if they are X days old or older.
This command, when run in a terminal as the user who owns the dir, works;
find /home/derakupload/subdomain -mindepth 1 -mmin +1 -delete
The issues arise with CRON, which refuse to run this command.
I enter CRON using sudo crontab -e
and have 2 entries right now;
* * * * * derakupload find '/home/derakupload/subdomain' -mindepth 1 -mmin +1 -delete
* * * * * derakupload /opt/script/delete_files_older_than
The script in the lower job looks like this
#!/bin/bash
find $HOME/subdomain -mindepth 1 -type f -mmin +1 -delete
I have tried to run it at specific times as opposed to just wilfcarding it all, didn't work.
I have no idea what I'm doing wrong anymore.
grep CRON /var/log/syslog
. Also using the $HOME variable when running as sudo will most likely look in the user ROOT home, not derakupload. When you're running commands in a script like that you should specify the whole path explicitly. – Gansheim Apr 06 '17 at 16:54