Thanks again!!!
]]>Don't forget to mark the topic as solved.
]]>Here it is the uptime.service's final version:
[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target
[Service]
ExecStart=/bin/true
ExecStop=/etc/rc.local.shutdown
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target
Now, it works!
Many thanks to MK13
]]>systemctl status uptime
after starting the service manually and
journalctl -b -u uptime
[jribeiro@arkosta ~]$ cat /usr/lib/systemd/system/uptime.service
[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target
[Service]
ExecStart=/bin/true
ExecStop=/etc/rc.local.shutdown
RemainAfterExit=yes
[Install]
WantedBy=shutdown.target
Then I started the uptime service manually:
[jribeiro@arkosta ~]$ sudo systemctl start uptime
I checked the 'registo_de_uptime' file:
[jribeiro@arkosta ~]$ cat /home/jribeiro/registo_de_uptime
Sáb Out 25 19:43:31 WEST 2014 - 2 min
After that I rebooted my system.
I checked the 'registo_de_uptime' file, again:
[jribeiro@arkosta ~]$ cat /home/jribeiro/registo_de_uptime
Sáb Out 25 19:43:31 WEST 2014 - 2 min
Sáb Out 25 19:44:27 WEST 2014 - 3 min
Everything seems to be alright. I wanted to make the ultimate test.
With that in mind I rebooted the system.
I checked the 'registo_de_uptime' file, once more:
[jribeiro@arkosta ~]$ cat /home/jribeiro/registo_de_uptime
Sáb Out 25 19:43:31 WEST 2014 - 2 min
Sáb Out 25 19:44:27 WEST 2014 - 3 min
No success...
It works when I start the service manually and in the right next reboot, after that it won't work.
Here is the journal's ouput:
[jribeiro@arkosta ~]$ sudo journalctl -b -0 -u uptime
-- Logs begin at Sex 2014-10-24 22:02:03 WEST, end at Sáb 2014-10-25 20:05:29 WEST. --
By the way:
[jribeiro@arkosta ~]$ sudo systemctl status uptime
● uptime.service - /etc/rc.local.shutdown Compatibility
Loaded: loaded (/usr/lib/systemd/system/uptime.service; enabled)
Active: inactive (dead)
sudo journalctl -b -0 -u uptime
Try altering your unit file to
[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target
[Service]
ExecStart=/bin/true
ExecStop=/etc/rc.local.shutdown
RemainAfterExit=yes
[Install]
WantedBy=shutdown.target
Then starting the service manually and shutdown afterwards.
]]>After starting the service the 'registo_de_uptime' is modified:
[jribeiro@arkosta ~]$ cat /home/jribeiro/registo_de_uptime
Sáb Out 25 13:36:29 WEST 2014 - 4 min
Then I rebooted my system and I checked the 'registo_de_uptime' file:
[jribeiro@arkosta ~]$ cat /home/jribeiro/registo_de_uptime
Sáb Out 25 13:36:29 WEST 2014 - 4 min
No changes...
P.S.: I tried same thing with "echo "$(date)" >> /home/jribeiro/uptime" and the result is equal. The file changes manually but don't changes automatically.
]]>On my machine, with the stripped unit file and the script with the shebang, everything works fine. Lets double check that before moving on:
Replace the content of the rc.local.shutdown script with
#!/bin/bash
echo "$(date)" >> /home/jribeiro/uptime
and try to start the service again via
systemctl start uptime
and check whether a file called 'uptime' is present in your home folder.
The status query of the uptime service shows that the service run without errors so it should work...
]]>[jribeiro@arkosta ~]$ sudo systemctl -l status uptime
● uptime.service - /etc/rc.local.shutdown Compatibility
Loaded: loaded (/usr/lib/systemd/system/uptime.service; enabled)
Active: inactive (dead) since Sex 2014-10-24 22:39:28 WEST; 10s ago
Process: 6220 ExecStart=/etc/rc.local.shutdown (code=exited, status=0/SUCCESS)
Main PID: 6220 (code=exited, status=0/SUCCESS)
Could you please
systemctl start uptime
systemctl -l status uptime
[jribeiro@arkosta ~]$ journalctl -u uptime
-- Logs begin at Sex 2014-10-24 22:02:15 WEST, end at Sex 2014-10-24 22:10:39 WEST. --
sudo journalctl -u uptime says:
[jribeiro@arkosta ~]$ sudo journalctl -u uptime
-- Logs begin at Sex 2014-10-24 22:02:03 WEST, end at Sex 2014-10-24 22:12:07 WEST. --
/usr/lib/systemd/system/uptime.service:
[jribeiro@arkosta ~]$ sudo cat /usr/lib/systemd/system/uptime.service
[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target
[Service]
ExecStart=/etc/rc.local.shutdown
[Install]
WantedBy=shutdown.target
Still no success...
]]>What does
journalctl -u uptime
say?
Also, try to strip everything from your unit file that is not absolutely necessary for your service to work. You might try:
[Unit]
Description=/etc/rc.local.shutdown Compatibility
Before=shutdown.target
[Service]
ExecStart=/etc/rc.local.shutdown
[Install]
WantedBy=shutdown.target
Further, try a simple script that only creates a file in your home folder as target.
EDIT: What solved the issue on my machine: Add
#!/bin/bash
to the script. See [SOLVED]Starup sript not getting executed in systemd
]]>It may be better to keep your own services under /etc/systemd/system instead of /usr/lib/...
Maybe a dependency issue e.g.
After=rc-local.service basic.target
?
]]>