You are not logged in.

#1 2015-04-27 21:33:00

dwsmith
Member
Registered: 2015-04-07
Posts: 18

How do I check if my systemd service and timer is setup correctly?

I setup a systemd service and timer to run weekly, but I don't know if it is setup correctly.

How I setup the service and timers was I first created a bash script in /usr/local/bin

#!/bin/bash
/usr/bin/profile-cleaner -c &
/usr/bin/browser-vacuum

I then made it executable with sudo chmod +x myscripts.

I created the following service myscripts.service file in /etc/systemd/system

[Unit]
Description=runs a script that calls profile-cleaner -c and browser-vacuum

[Service]
WorkingDirectory=/usr/local/bin
Type=simple
ExecStart=/bin/bash myscript

[Install]
WantedBy=mytimer.target

Next I created a mytimer.timer file in /etc/systemd/system

[Unit]
Description=Run my timers services weekly

[Timer]
OnCalendar=weekly
Persistent=true
Unit=myscripts.service

[Install]
WantedBy=multi-user.target

Will this setup work or am I missing something in the setup process?

Thanks.

Last edited by dwsmith (2015-04-27 21:55:13)

Offline

#2 2015-04-27 22:35:45

firecat53
Member
From: Lake Stevens, WA, USA
Registered: 2007-05-14
Posts: 1,542
Website

Re: How do I check if my systemd service and timer is setup correctly?

The timer and the service file need to have the same basename (i.e. myscript.service and myscript.timer).  Hopefully you referenced this :-;

Scott

Offline

#3 2015-04-27 22:40:25

dwsmith
Member
Registered: 2015-04-07
Posts: 18

Re: How do I check if my systemd service and timer is setup correctly?

firecat53 wrote:

The timer and the service file need to have the same basename (i.e. myscript.service and myscript.timer).  Hopefully you referenced this :-;

Scott

Other than the uniform name, it should be okay?

Offline

#4 2015-04-27 22:42:26

Raynman
Member
Registered: 2011-10-22
Posts: 1,539

Re: How do I check if my systemd service and timer is setup correctly?

firecat53 wrote:

The timer and the service file need to have the same basename (i.e. myscript.service and myscript.timer).

Not true (see your own link). But it might be simpler to stick to that convention.

It is strange to set the working directory and then pass a relative path to /bin/bash. Similarly, why chmod +x the script if you're going to invoke /bin/bash explicitly?

The [Install] section in the .service file is also not needed unless you want to do something else with that mytimer.target.

Offline

Board footer

Powered by FluxBB