Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230
Is /etc/rc.local obsolete? [Solved]
Is /etc/rc.local obsolete? [Solved]
I"ve tried running scripts inside that file but it doesn't work, so then I moved my script file to /etc/init.d and after a restart, the script worked. Does that mean rc.local is obsolete?
Last edited by G-Known on 2015-10-04 02:21, edited 1 time in total.
Debian Jessie
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
- GarryRicketson
- Posts: 5644
- Joined: 2015-01-20 22:16
- Location: Durango, Mexico
Re: Is /etc/rc.local obsolete?
No it is not "obsolete" , it has it's place, and it'uses ,..
Some people, seem to feel it is obsolete. But that would depend on what version of Debian you are using, what kind of script it is, and if the script is "called" correctly.
so many other details, none of which you have given.
Why didn't you just copy and paste the question into a search engine, Like "startpage.com" ?
Copy and paste , :
-----------------------
I guess the script you wrote, is the kind of script that needs to be run from init.d
Try
Is DOS obsolete ? many people would say yes, I would say no, cause I still use it,
Same applies to /etc/rc.local , it has it's uses, but if the person does not know how to use it, then it is "obsolete".
http://unix.stackexchange.com/questions ... c-rc-localDoes that mean rc.local is obsolete?
Some people, seem to feel it is obsolete. But that would depend on what version of Debian you are using, what kind of script it is, and if the script is "called" correctly.
so many other details, none of which you have given.
Why didn't you just copy and paste the question into a search engine, Like "startpage.com" ?
Copy and paste , :
into https://startpage.com/do/metasearch.plIs /etc/rc.local obsolete?
-----------------------
I guess the script you wrote, is the kind of script that needs to be run from init.d
Try
Code: Select all
man bash
Same applies to /etc/rc.local , it has it's uses, but if the person does not know how to use it, then it is "obsolete".
"What we expect you have already Done"
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
==========
Old Website
======================
For the Birds
==================
What Does a Parrot Know About PTSD?
-
- Posts: 34
- Joined: 2015-08-26 11:31
Re: Is /etc/rc.local obsolete?
No, not obsolete. It is provided for the use of the system administrator and compatibility reasons. Posts that insist it should never be used are just plain wrong.G-Known wrote:I"ve tried running scripts inside that file but it doesn't work, so then I moved my script file to /etc/init.d and after a restart, the script worked. Does that mean rc.local is obsolete?
I run hdparm -B 254 /dev/sdX from /etc/rc.local to kill head parking on my HGST drives at startup. I also kill display power management and launch the fancontrol script from /etc/rc.local.
As would be expected, rc.local has to be enabled in systemd. I am on Stretch which I installed with the testing network installer. As far as I can recall, enabled was the default. The Stretch systemd rc.local settings are a little different than those in Arch, (as referenced by those earlier links), so it may not be wise to rely on directly copying Arch stuff in this case.
Code: Select all
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.
# This unit gets pulled automatically into multi-user.target by
# systemd-rc-local-generator if /etc/rc.local is executable.
[Unit]
Description=/etc/rc.local Compatibility
ConditionFileIsExecutable=/etc/rc.local
After=network.target
[Service]
Type=forking
ExecStart=/etc/rc.local start
TimeoutSec=0
RemainAfterExit=yes
Lastly, anything that isn't a simple, quick command has to be forked in rc.local. Anything that returns an error will immediately terminate rc.local and subsequent entries will not be executed.
Re: Is /etc/rc.local obsolete?
I'm trying to run this script:
I've inputted it into init.d directory but it doesn't seem to run. I've made it executable and used the update-rc.d 'script.sh' default command.
I've used the rc.local file before and I know its basic functions. But lately, even if I put an input command like: nmcli radio wifi off, the command won't get executed. I don't know how to diagnose this error but generally the command is prior 'exit 0'. My current file reads:
Code: Select all
#!/bin/bash
while true
do
export DISPLAY=:0.0
battery_level=`acpi -b | grep -P -o '[0-9]+(?=%)'`
if on_ac_power; then
if [ $battery_level -ge 80 ]; then
notify-send "Battery charging above 80%. Please unplug your AC adapter!" "Charging: ${battery_level}% "
sleep 20
if on_ac_power; then
gnome-screensaver-command -l ## lock the screen if you don't unplug AC adapter after 20 seconds
fi
fi
else
if [ $battery_level -le 35 ]; then
notify-send "Battery is lower 35%. Need to charging! Please plug your AC adapter." "Charging: ${battery_level}%"
sleep 20
if ! on_ac_power; then
gnome-screensaver-command -l ## lock the screen if you don't plug AC adapter after 20 seconds
fi
fi
fi
sleep 300 # 300 seconds or 5 minutes
done
I've used the rc.local file before and I know its basic functions. But lately, even if I put an input command like: nmcli radio wifi off, the command won't get executed. I don't know how to diagnose this error but generally the command is prior 'exit 0'. My current file reads:
Code: Select all
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
nmcli radio wifi off
ethtool -s eth0 wol d
exit 0
Last edited by G-Known on 2015-09-19 12:35, edited 1 time in total.
Debian Jessie
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
-
- Posts: 34
- Joined: 2015-08-26 11:31
Re: Is /etc/rc.local obsolete?
First, make sure rc.local is running.
Then try this.
I did not look at the bash script you posted. I am far from a bash expert, and I don't have the time to try and dig through it. I also did not verify the correctness of your nmcli and ethtool usage.
Code: Select all
$ systemctl list-units | grep rc-local
rc-local.service loaded active running /etc/rc.local Compatibility
Code: Select all
# By default this script does nothing.
nmcli radio wifi off &
ethtool -s eth0 wol d &
exit 0
- kiyop
- Posts: 3983
- Joined: 2011-05-05 15:16
- Location: Where persons without desire to improve themselves fear to tread, in Japan
- Been thanked: 3 times
Re: Is /etc/rc.local obsolete?
Are you sure that there is "done" after the last "fi" in the script?
If there is not, the script has a BUG, and so it is not executed because of error.
Refer, for example, http://tldp.org/LDP/Bash-Beginners-Guid ... 09_02.html
If there is, read below.
How do you confirm that the script is not executed?
Execute
and find the script or "sleep 300".
Are you sure that in your debian, the variable $battery_level has some value?
Sometimes, the current (working) directory and the current $PATH variable and the current user (root or the ordinary user) cause problems.
If there is not, the script has a BUG, and so it is not executed because of error.
Refer, for example, http://tldp.org/LDP/Bash-Beginners-Guid ... 09_02.html
If there is, read below.
How do you confirm that the script is not executed?
Execute
Code: Select all
ps auwwx
Are you sure that in your debian, command "on_ac_power" exist?G-Known wrote:Code: Select all
while true do (snip by kiyop) if on_ac_power; then if [ $battery_level -ge 80 ]; then (snip by kiyop) fi fi sleep 300 # 300 seconds or 5 minutes
Code: Select all
on_ac_power
Code: Select all
echo $battery_level
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
http://kiyoandkei.bbs.fc2.com/
Re: Is /etc/rc.local obsolete?
I know that the script works because if I run it manually, it'll work. I'll double check the script soundness.
pgrep -fl will return to me the script that it's running.
UPDATE: The done was placed at the end after the 'sleep' statement. I believed I didn't paste that part in.
pgrep -fl will return to me the script that it's running.
UPDATE: The done was placed at the end after the 'sleep' statement. I believed I didn't paste that part in.
Last edited by G-Known on 2015-09-19 12:36, edited 2 times in total.
Debian Jessie
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Re: Is /etc/rc.local obsolete?
The command returns:WingedFrog wrote:First, make sure rc.local is running.
Code: Select all
$ systemctl list-units | grep rc-local rc-local.service loaded active running /etc/rc.local Compatibility
Code: Select all
rc-local.service loaded active exited /etc/rc.local Compatibility
Debian Jessie
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
- kiyop
- Posts: 3983
- Joined: 2011-05-05 15:16
- Location: Where persons without desire to improve themselves fear to tread, in Japan
- Been thanked: 3 times
Re: Is /etc/rc.local obsolete?
G-Known addedG-Known wrote:UPDATE: The done was placed at the end after the 'sleep' statement. I believed I didn't paste that part in.
to the above post of him: http://forums.debian.net/viewtopic.php? ... 21#p593167G-Known wrote:Code: Select all
done
after I posted the above.
To G-Known,
G-Known wrote:pgrep -fl will return to me the script that it's running.
I see. I cannot help you. Good luck and good-bye.G-Known wrote:I know that the script works because if I run it manually, it'll work. I'll double check the script soundness.
Openbox, JWM: Jessie, Sid, Arch / Win XP (on VirtualBox), 10
http://kiyoandkei.bbs.fc2.com/
http://kiyoandkei.bbs.fc2.com/
Re: Is /etc/rc.local obsolete? [Solved]
I did it. Unfortunately I'll have to remove the script from init.d directory; it seems root is unable to execute whilst successfully in userspace.
Debian Jessie
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
Asus Zenbook UX305FA-ASM1
Intel Core M 5Y10; Intel HD Graphics 5300
-
- Posts: 5
- Joined: 2016-06-30 22:07
Re: Is /etc/rc.local obsolete? [Solved]
As I googled "debian 9 /etc/rc.local" and it returned me this forum page, I would like to share information about /etc/rc.local on Debian 9.0 Stretch, just in case anyone needs. This is not official information, but what happened to me and how I solved it.
I needed to run a script at my server startup. I installed Debian 9.0 Stretch RC 4 yesterday using the netinst CD image available here: https://www.debian.org/devel/debian-installer/
When I issued:
I noticed nano was creating a new file. In other words, /etc/rc.local is not created by default on Debian 9.0 Stretch.
I copied the template from another Debian server I have, running Debian 8.0 Jessie:
And I added a call to the script before exit 0. Then, I rebooted the server, the script was not executed. I thought /etc/rc.local was not used on Debian 9.0 anymore, so I googled and came to this page.
Then, reading the post and the replies, I followed their directions:
Besides manually creating /etc/rc.local, I should have made it executable, so I did it and rebooted the server:
That time, the script was called during startup.
I needed to run a script at my server startup. I installed Debian 9.0 Stretch RC 4 yesterday using the netinst CD image available here: https://www.debian.org/devel/debian-installer/
When I issued:
Code: Select all
# nano /etc/rc.local
I copied the template from another Debian server I have, running Debian 8.0 Jessie:
Code: Select all
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
exit 0
Then, reading the post and the replies, I followed their directions:
Code: Select all
# systemctl list-units | grep rc-local <-- (empty output)
# systemctl start rc-local
# systemctl status rc-local
● rc-local.service - /etc/rc.local Compatibility
Loaded: loaded (/lib/systemd/system/rc-local.service; static; vendor preset: enabled)
Drop-In: /lib/systemd/system/rc-local.service.d
└─debian.conf
Active: inactive (dead)
Condition: start condition failed at Wed 2017-06-07 09:54:07 -03; 3s ago
└─ ConditionFileIsExecutable=/etc/rc.local was not met
Code: Select all
# chmod +x /etc/rc.local
# reboot
Re: Is /etc/rc.local obsolete? [Solved]
Exists but is inactive, here explain how to activate it
https://www.linuxbabe.com/linux-server/ ... th-systemd
https://www.linuxbabe.com/linux-server/ ... th-systemd