Does that mean rc.local is obsolete?
into https://startpage.com/do/metasearch.plIs /etc/rc.local obsolete?
man bash
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?
# 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
#!/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
#!/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
$ systemctl list-units | grep rc-local
rc-local.service loaded active running /etc/rc.local Compatibility
# By default this script does nothing.
nmcli radio wifi off &
ethtool -s eth0 wol d &
exit 0
ps auwwx
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
on_ac_power
echo $battery_level
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
rc-local.service loaded active exited /etc/rc.local Compatibility
G-Known wrote:UPDATE: The done was placed at the end after the 'sleep' statement. I believed I didn't paste that part in.
G-Known wrote:
- Code: Select all
done
G-Known wrote:pgrep -fl will return to me the script that it's running.
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.
# nano /etc/rc.local
#!/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
# 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
# chmod +x /etc/rc.local
# reboot
Return to System configuration
Users browsing this forum: No registered users and 9 guests