² SystemD : timer & service #
???????????
Edit this below: "<<<<<<<<<<<<<"
???????????
Variables:
_function_name=f_send_to_litterbox_then_ntfy
_function_path=$HOME/"$_function_name".sh`
???????????
I think foo.timer need not be in /etc/systemd/system/
cuz systemctl start ~/foo makes links to etc
???????????
sudo nano ~/"$_function_name".{timer,service}
sudo ln -s ~/"$_function_name".{timer,service} /etc/systemd/system/
# /etc/systemd/system/foo.timer
[Unit]
Description=Run "$_function_name" every 5 minutes
[Timer]
OnUnitActiveSec=5min
Unit="$_function_name".service
[Install]
WantedBy=timers.target
# /etc/systemd/system/foo.service
[Unit]
Description=Execute "$_function_name"
[Service]
Type=oneshot
ExecStart="$_function_path"
[Install]
WantedBy=multi-user.target
# /etc/systemd/system/foo.timer
[Unit]
Description="$_function_name every 2 sec"
[Timer]
Unit="$_function_name".service
OnUnitActiveSec=2
#OnUnitActiveSec=2h 30min # see systemd.time(7)
#OnUnitActiveSec=5min
[Install]
WantedBy = timers.target
AccuracySec= <<<<<<<<<<<<<<<<<<<<<<<
RandomizedDelaySec= Defaults to 0 <<<<<<<<<<<<<<<<<<<<<<<
sudo systemctl daemon-reload
for i in enable start; do
sudo systemctl "$i" "$_function_name".{service,timer}
done
sudo systemctl status "$_function_name".service
sudo systemctl show "$_function_name".service
sudo systemctl disable "$_function_name".service
sudo systemctl enable "$_function_name".service
??????? needed ??????///
NO
sudo chown root:root /home/mabox/date.sh
last updated:
