So let's see what you're doing here:
/bin/find . -maxdepth 1 -type d -ctime +2 -exec /bin/rm -rf {} \;
Find all folders in the current directory (.
) created more than 2 days ago and execute rm -rf
on it.
The current working directory for a cronjob is the users home directory, for root
/sudo
cronjobs it is /root
.
If you were really lucky, you used sudo crontab
, and it did no harm, as /root
directory is usually not used in Ubuntu.
If not, you basically deleted all directories older than 2 days in your home. This should be more or less anything of importance. Desktop
, Pictures
, Documents
, .config
...
What you should do instead:
Use full paths:
/bin/find /path/to/my/folder -maxdepth 1 -type d -ctime +2 -exec /bin/rm -rf {} \;
In any way
- be very careful with
rm -rf
, and do not use it unless you're 100% sure about it.
- have a backup ready.
$HOME
that is more than 2 days old ? Or have you been lucky and usedsudo crontab
...find
is in/usr/bin/find
...