I have a nodejs gui program (does not requires user interaction), which needs to be run at every 40th minutes at each hour. Say run at 05:40PM, 06:40PM, 07:40PM and so on. In a Debian server, I have enabled a systemd timer using:
systemctl --user enable my_program.timer Problem is, scheduling starts at the given time and finishes successfully. But immediately after that program starts again and finishes successfully.
Say program started at 5:40PM and finished at 5:45PM. After a minute or so, say at 5:46PM program starts again and finishes. Then this happens again at next time, so at 6:40PM.
This happens every time every hour. Also, if I reboot the server, after logging into that user account, program starts immediately instead of waiting 5 minute.
- How to stop auto running second time?
- How to force to start 5 minutes after reboot?
Content of /home/user/schedule.sh
#! /usr/bin/bash cd /home/user/my_program && DISPLAY=:0 /usr/bin/node ./index.js Content of /home/user/.config/systemd/user/my_program.service
[Unit] Description=My Program [Service] ExecStart=/home/user/schedule.sh Content of /home/user/.config/systemd/user/my_program.timer
[Unit] Description=My Program Timer Requires=my_program.service [Timer] Unit=my_program.service OnCalendar=*-*-* *:40:* OnBootSec=5 minutes [Install] WantedBy=timers.target
OneBootSecshould beOnBootSec.OnBootSec=5min.