You are not logged in.
Pages: 1
So, I've got a small problem with an assignment for my scripting course at the University. Almost there, all i need to do is to get a script to run once a minute. Basicly, i want to run a bash-script called bash_script.sh in the $HOME/projekt folder.
Read man page, wiki and some random stuff after google, but i can't get this thing to run.
Permissions to run the script is ok and the script itself is working properly.
Tried to start and enable both the timer and service with systemctl. Even tried just to start and enable the timer. Also tried with timer and service from both /etc/systemd/system and /usr/lib/systemd/system . Timer seems to be running when using systemctl list-timers .
Now I'm all out of ideas and now need some help.
Timer:
[Unit]
Description=Run wfreq.service every minute
[Timer]
OnBootSec=5min
OnUnitActiveSec=1min
Unit=wfreq.service
[Install]
WantedBy=multi-user.target
Service:
[Unit]
Description=Run bash_script.sh
[Service]
Type=simple
ExecStart=/bin/bash $HOME/projekt/bash_script.sh
[Install]
WantedBy=multi-user.target
Last edited by melw (2015-06-20 09:44:11)
I know I'm paranoid, but am I paranoid enought....
Offline
The most glaring issue is that systemd has no idea what $HOME is. And even if that is passed verbatim to bash and bash interprets it, bash will interpret that as /root/projekt/... which I don't think is what you mean.
Also, type should be 'oneshot', and there should be not [Install] in the service - though i don't know if this would hurt anything.
In the timer, you don't need to specify the service Unit if they have the same base name. And in the [Install] portion of the timer, it should be timers.target not multi-user.
Lastly, don't enable the service, just the timer.
"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman
Offline
Have you considered making that a user service?
Your script goes into ~/.config/systemd/user/
Enable it with systemctl --user enable ... I think you can put a timer in there. Try it
Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
Sometimes it is the people no one can imagine anything of who do the things no one can imagine. -- Alan Turing
---
How to Ask Questions the Smart Way
Offline
You can use %h instead of $HOME after you make it a user service (or set User=).
and there should be not [Install] in the service - though i don't know if this would hurt anything.
[..]
Lastly, don't enable the service, just the timer.
If you don't enable it the [Install] section is simply ignored. Removing the [Install] section would effectively disable the (in this unwanted) enable command for the service.
Offline
It's now working.
Made the changes in both timer and service suggested by Trillby. Still had some problem with the script trying to use the wrong directory.
Then i tried the --user version suggested by ewaller and it's now working as it's supposed to.
Thanks to you both!
I know I'm paranoid, but am I paranoid enought....
Offline
Pages: 1