How to launch LSB script from rc0.d?
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 After creating the file (~./empty-trash) I did the following: Code:
# mv empty-trash /etc/init.d/ I "uninstalled" the script an edited it: Code:
# update-rc.d -f empty-trash remove Code:
#! /bin/sh Code:
# update-rc.d empty-trash defaults What am I doing wrong? Can anybody help me, please? Sorry for my bad English and thanks in advance! |
The $all means run as the last script which is not going to work for runlevel 0. I would say you want the script to first but using $local_fs for the Required-Stop will at least start your your script prior to the local file systems unmounting.
|
Thank you for the response but it is incorrect in this case. It is correct for 'S' scripts but it is impossible to launch any 'S' script in runlevel 0 because a 'S' script will be called later than the last 'K' script. But the last 'K' script refers to halt.
With 'Required-Stop: $all' it places a symlink to my script at the first place in /etc/rc0.d but it still does not work. BTW, I already tried 'Required-Stop: $local_fs' and some other values and combinations but with no success. |
Ok, guess I did not understand the https://wiki.debian.org/LSBInitScripts/ wiki but since update-rc.d does place your script in rc0.d and as k01... then $all is not the problem. I did try your script on a debian 7 and it ran and then finally tried it on a version 8 vm. The first time it didn't run but the second time it did. Not sure what I did to get it to work.
|
It is strange... Did you try my second script? The first one works fine for me, too.
IMO, the problem is more deeper. Maybe I need to add something to a line 'Should-stop'? I tried 'Should-stop: $all' - no difference. Or maybe sendsigs kills my script too quickly? |
My script does delete all old files and dirs from the Trash. But any symlinks it doesn't. There is a solution:
Code:
#! /bin/sh The old variant: Code:
-type f The new variant: Code:
! -type d But I still can't make my script work at runlevel 0. Has somebody any ideas? |
Well, I just fixed this. There is my new script below:
Code:
#!/bin/sh I opened the file '/etc/lightdm/lightdm.conf' (as root) and uncommented the line 'session-cleanup-script=' and added here the path to my script. I saved the file and that's all. It is not exactly a LSB script and it does not run directly from rc0.d but it runs at runlevel 0 only and works as expected. |
All times are GMT -5. The time now is 12:47 AM. |