0

I have created a ServiceName.service file.

[Unit]
Description=ServiceName Service
After=network.target

[Service]
ExecStart=/usr/local/bin/<scriptName>.sh

And I have create a ServiceName.timer file.

[Unit]
Description=ServiceName timer to start weekly

[Timer]
#reboot
OnBootSec=1min
#weekly
OnUnitActiveSec=1w
Unit=ServiceName.service

[Install]
WantedBy=multi-user.target

The .sh file starts a webpage and a search with new results for the webpage that needs to be accessible for a week, and then perform a new search.

The scripts starts on boot, so that part works. But it seems that the script has to shutdown the service first before the timer function works. I have no clue on how to do that.

0

Welcome to Unix & LinuxStackExchange.

First, you probably want After=network-online.target to make sure the network is fully up.

Second, you must systemctl enable ServiceName.timer so that the timer will get started at boot. Did you do that? Use systemctl list-timers to check to see which are running.

Third, update your timer file to use WantedBy=timers.target which is the recommended target.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.