You are not logged in.
First of all I know that my problem can be solved by just running cron but that is not the point here. I am trying this to see how well it works. I followed the setup instructions on the systemd/cron functionality, and I created a fake hourly service to be able to watch it work. The unit file for this is
[Unit]
Description=Run a test (echo) job every hour
[Service]
Nice=19
IOSchedulingClass=2
IOSchedulingPriority=7
ExecStart=/bin/echo "I ran via a hourly job in SystemD" >> /tmp/test.log
The problem is it does not seem that the service file is being ran as a /tmp/test.log file never gets created. Anyone ever play with this part of SystemD and get it working?
Offline
What's the status of this service and related timers?
Offline
ExecStart is not a shell. You cannot put redirects there without first spawning a shell.
Offline
What's the status of this service and related timers?
Here is the status of the timers are:
timers.target: loaded active active
timer-daily.timer: loaded active waiting
timer-hourly.timer: loaded active waiting
timer-weekly.timer: loaded active waiting
That suggests to me that the timers are working, I don't see my test service under systemctl's output, but I see another service that I wrote to sync pacman's DB every hour has failed. This is why I wrote the second service file in hopes to see if this was working.
Offline
Again, ExecStart is not a shell. So the redirected echo command is not going to work since redirections are a function of a shell.
Offline
I understand that ExecStart does not support redirection as it is not a shell, which is why I wrote "in hopes". The systemctl status and journalctl commands don't output anything useful to see why it was not working, I did that because I did not know any other way to debug this.
Offline
Would 'ExecStart=/usr/bin/touch /tmp/test' work?
Offline
Yeah that would work. But you could also do something like:
ExecStart=/usr/bin/bash -c "/usr/bin/echo foo >> /path/to/file"
Edit: That is what I was trying to point you to in saying you needed to spawn a shell. But you could also just write a script as well that is launched by ExecStart. I think you need to make sure that it has a valid shebang though.
Last edited by WonderWoofy (2013-12-15 01:34:00)
Offline