Hello here!
I am a newbie in Linux. I've Debian 8.2 & LXDE on my desktop PC. I'd like to make a script to empty a trash can automatically. I've found an aversome script
here. I changed it a little and added an "INIT INFO" block. Here it is:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides: empty-trash
# Required-Start:
# Required-Stop:
# Default-Start: 5
# Default-Stop:
# Short-Description: Empty Trash
### END INIT INFO
DAYS=-1
find /home/username/.local/share/Trash -type f -mtime +$DAYS -delete
find /home/username/.local/share/Trash/files/* -depth -type d -exec rmdir --ignore-fail-on-non-empty {} +
exit 0
"DAYS=-1" - it is just for test, it will be increased.
After creating the file (~./empty-trash) I did the following:
Code:
# mv empty-trash /etc/init.d/
# cd /etc/init.d
# chown root:root empty-trash
# chmod +x empty-trash
# update-rc.d empty-trash defaults
...and my script worked fine. But I'd like to launch it at shutdown.
I "uninstalled" the script an edited it:
Code:
# update-rc.d -f empty-trash remove
# leafpad /etc/init.d/empty-trash
Here is the edited script:
Code:
#! /bin/sh
### BEGIN INIT INFO
# Provides: empty-trash
# Required-Start:
# Required-Stop: $all
# Default-Start:
# Default-Stop: 0
# Short-Description: Empty Trash
### END INIT INFO
DAYS=-1
find /home/username/.local/share/Trash -type f -mtime +$DAYS -delete
find /home/username/.local/share/Trash/files/* -depth -type d -exec rmdir --ignore-fail-on-non-empty {} +
exit 0
I saved the script and launched:
Code:
# update-rc.d empty-trash defaults
...and my script stopped to work.
What am I doing wrong? Can anybody help me, please?
Sorry for my bad English and thanks in advance!