[systemd-devel] systemd services running on VM nodes 1 and 2 in High Availability Mode.

Kaushal Shriyan kaushalshriyan at gmail.com
Tue Aug 17 10:39:21 UTC 2021


Hi,

I have created a systemd script along with the timer which runs once every
three hours. I have the same settings across node1 and node2 which are
hosted behind the load balancer. The reason setting behind LB is to make
sure we avoid a single point of failure scenarios. I have a specific issue
here both the systemd tasks are doing the same job which will result in
*duplication*. Is there a way to set it in such a way that node1 systemd
tasks should run all the time and if node1 goes down in an event of failure
then node2 systemd service will trigger the tasks.  Can systemd service on
node1 talk to node2 and vice versa? Please suggest.

*Node1*
[root at devplace-dev-vm1]#cat /etc/systemd/system/checkeverythreehours.service
[Unit]
Description=checkeverythreehours
[Service]
Type=simple
User=deployuser
ExecStart=/bin/bash /var/www/html/dsc/devplace/externaldrupalcron.sh
[root at devplace-dev-vm1]#cat /etc/systemd/system/checkeverythreehours.timer
[Unit]
Description=A timer that runs once in every three hours
Requires=checkeverythreehours.service

[Timer]
Unit=checkeverythreehours.service
AccuracySec=1us
OnUnitActiveSec=10800
Persistent=true

[Install]
WantedBy=timers.target
[root at devplace-dev-vm1]#

*Node2*
[root at devplace-dev-vm2]#cat /etc/systemd/system/checkeverythreehours.service
[Unit]
Description=checkeverythreehours
[Service]
Type=simple
User=deployuser
ExecStart=/bin/bash /var/www/html/dsc/devplace/externaldrupalcron.sh
[root at devplace-dev-vm2]#cat /etc/systemd/system/checkeverythreehours.timer
[Unit]
Description=A timer that runs once in every three hours
Requires=checkeverythreehours.service

[Timer]
Unit=checkeverythreehours.service
AccuracySec=1us
OnUnitActiveSec=10800
Persistent=true

[Install]
WantedBy=timers.target
[root at devplace-dev-vm2]#

Thanks in advance.

Best Regards,

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/systemd-devel/attachments/20210817/b248b65c/attachment-0001.htm>


More information about the systemd-devel mailing list