You are not logged in.

#1 2016-09-26 12:52:07

Dun
Member
Registered: 2014-12-28
Posts: 98

[SOLVED]cron and systemd timer not working

So I want to execute this line every minute on my computer: "/usr/bin/gcalcli remind". When I'm executing it, a small red box with my closest appointments will appear.

I've tried using cron and systemd, but both are not executing the command. It doesn't spawn the red box once.

cron:

#( 26.09.16@14:43 )( dun@Arch64L ):~ sudo pacman -S cronie 
[sudo] password for dun: 
warning: cronie-1.5.1-1 is up to date -- reinstalling
resolving dependencies...
looking for conflicting packages...

Packages (1) cronie-1.5.1-1

Total Installed Size:  0.26 MiB
Net Upgrade Size:      0.00 MiB

:: Proceed with installation? [Y/n] 
(1/1) checking keys in keyring                                                    [##############################################] 100
(1/1) checking package integrity                                                  [##############################################] 100
(1/1) loading package files                                                       [##############################################] 100
(1/1) checking for file conflicts                                                 [##############################################] 100
(1/1) checking available disk space                                               [##############################################] 100
:: Processing package changes...
(1/1) reinstalling cronie                                                         [##############################################] 100
#( 26.09.16@14:43 )( dun@Arch64L ):~ systemctl start cronie.service 
#( 26.09.16@14:44 )( dun@Arch64L ):~ systemctl enable cronie.service 
Created symlink /etc/systemd/system/multi-user.target.wants/cronie.service → /usr/lib/systemd/system/cronie.service.
#( 26.09.16@14:36 )( dun@Arch64L ):~ EDITOR=gedit crontab -e

Then I entered this line

*/1 * * * * /usr/bin/gcalcli remind

At the end: Does not run the command every minute. Doesn't even execute ones.

systemd:

#( 26.09.16@14:38 )( dun@Arch64L ):~ sudo gedit /etc/systemd/system/gcalcliremind.service

Entered this:

[Unit]
Description=GCalCLIRemindService

[Service]
Type=simple
ExecStart="/usr/bin/gcalcli remind"
#( 26.09.16@14:45 )( dun@Arch64L ):~ sudo gedit /etc/systemd/system/gcalcliremind.timer

Entered this:

[Unit]
Description=Runs GCalCLIRemindService every minute

[Timer]
OnBootSec=1min
OnUnitActiveSec=1min
Unit=gcalcliremind.service

[Install]
WantedBy=multi-user.target

Started and enabled the timer, but nothing happens either. What am I doing wrong?

Last edited by Dun (2016-10-03 14:53:33)

Offline

#2 2016-09-26 13:25:42

ayekat
Member
Registered: 2011-01-17
Posts: 1,590

Re: [SOLVED]cron and systemd timer not working

gcalcli remind

What is that command supposed to do?

-- edit ---
I'm sorry, I haven't read the first line. Scimmia is probably right.

Last edited by ayekat (2016-09-26 13:30:48)


pkgshackscfgblag

Offline

#3 2016-09-26 13:29:10

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,559

Re: [SOLVED]cron and systemd timer not working

You're running the command as root.

Offline

#4 2016-09-26 13:39:57

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: [SOLVED]cron and systemd timer not working

Scimmia wrote:

You're running the command as root.

Sorry but I don't understand. What command am I running as root?

Offline

#5 2016-09-26 14:00:43

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,559

Re: [SOLVED]cron and systemd timer not working

The gcalcli one. It's beening run as the root user.

Offline

#6 2016-09-26 14:14:05

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

Re: [SOLVED]cron and systemd timer not working

With the systemd timer, yes, but it looks like the crontab for user 'dun'. But then cron would be completely disconnected from any X session, while $DISPLAY and the like are normally imported into the systemd manager for user services. So converting to user service and timer is probably good enough.

The ExecStart command line should not be quoted btw.

Offline

#7 2016-09-27 10:47:47

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: [SOLVED]cron and systemd timer not working

I uninstalled cron, because it didn't do anything. I've removed the mistakes in the systemd timer and tried it with them.

#( 27.09.16@11:38 )( dun@Arch64L ):~ sudo gedit /etc/systemd/system/gcalremind.timer
[b]gcalremind.timer[/b]
[Unit]
Description=Run GCalRemind

[Timer]
OnCalendar=*:0/1
#( 27.09.16@11:38 )( dun@Arch64L ):~ sudo gedit /etc/systemd/system/gcalremind.timer
[b]gcalremind.service[/b]
[Unit]
Description=GCalCLIRemindService

[Service]
Type=simple
ExecStart=/usr/bin/gcalcli remind

The problem now is, that I would have to authenticate with root, but I kinda don't want having my config-files in the root-folder. Is it possible to use systemd without root? I've never used sudo while starting and enabling the timer, so I don't really understand, why root does run it in the end.

Offline

#8 2016-09-27 11:07:36

ayekat
Member
Registered: 2011-01-17
Posts: 1,590

Re: [SOLVED]cron and systemd timer not working

Dun wrote:

Is it possible to use systemd without root?

https://wiki.archlinux.org/index.php/Systemd/User


pkgshackscfgblag

Offline

#9 2016-10-03 14:53:16

Dun
Member
Registered: 2014-12-28
Posts: 98

Re: [SOLVED]cron and systemd timer not working

Finally had time to work on this problem. The timer works now, running as a user service smile

Offline

Board footer

Powered by FluxBB