adding_services
"/home/yossef/notes/personal/linux/adding_services.md"
path: personal/linux/adding_services.md
- **fileName**: adding_services
- **Created on**: 2025-10-06 20:48:04
so now i gone tell how to make a services on archlinux or linux on general
so first must create a script for the services on this example i gone
create a services for battery check if it's battery low
now after creating the script for battery check
path: /home/fooo/test.sh
change dir to this place /home/yossef/.config/systemd/user
and create two files with the same name but different extension
- battery-check.service
- battery-check.timer
the content for the files is gone be
# - battery-check.service
[Unit]
Description=Battery level checker
[Service]
Type=oneshot
# oneshot: runs a short-lived command or script, does its job once
ExecStart=/home/foo/test.sh
## path for the file battery script
# - battery-check.timer
[Unit]
Description=Runs battery check every minute
OnBootSec=1min
[Timer]
OnBootSec=1min
# OnBootSec: "Wait 1 minute after system boot, then run the
# service for the first time."
OnUnitActiveSec=1min
# OnUnitActiveSec: This tells systemd: "Run the service 1 minute after
# it was last run."
# name of the service that you make
Unit=battery-check.service
[Install]
WantedBy=timers.target
#You can enable the timer with systemctl --user enable battery-check.timer
#It will then automatically run at login/startup, without needing manual start
and now after creating the two files and setup them run this commends
# for check for everything is right
systemd-analyze verify ~/.config/systemd/user/battery-check.service
# start the service
systemctl --user start battery-check.service
# reload the daemon and enable services forever
systemctl --user daemon-reload
systemctl --user enable --now battery-check.timer
continue:[[]]
before:./ls.md