0

I'm trying to run some commands upon every system boot in cronjob but it doesn't seem to be working, so far i have installed cron in Arch, enabled and started it with

systemctl enable cronie
systemctl start cronie

Then i went into a new crontab using

crontab -e

And added the following lines:

@reboot /bin/xbindkeys
@reboot /bin/setxkbmap -layout gb

I need these two commands to run on startup ever time, the first command is to start xbindkeys, and the second is to set my keyboard layout to GB layout. When i rebooted my system the crontab didn't seem to do anything, id appreciate if i can get some help, Thanks!

EDIT: Here is the output of:

journalctl -xe | grep CRON
Aug 26 14:30:48 archlinux crond[329]: (CRON) STARTUP (1.5.5)
Aug 26 14:30:48 archlinux crond[329]: (CRON) INFO (Syslog will be used instead of sendmail.)
Aug 26 14:30:48 archlinux crond[329]: (CRON) INFO (RANDOM_DELAY will be scaled with factor 5% if used.)
Aug 26 14:30:48 archlinux crond[329]: (CRON) INFO (running with inotify support)
Aug 26 14:30:49 archlinux CROND[423]: (user1) CMD (/bin/xbindkeys)
Aug 26 14:30:49 archlinux CROND[424]: (user1) CMD (/bin/setxkbmap -layout gb)
Aug 26 14:30:49 archlinux CROND[348]: (user1) CMDOUT (Cannot open display "default display")
Aug 26 14:30:49 archlinux CROND[348]: pam_unix(crond:session): session closed for user user1
Aug 26 14:30:50 archlinux CROND[349]: pam_unix(crond:session): session closed for user user1

2
  • Apart from the fact that these commands look like an XY-problem, my best bet is that the cron job is executed too soon (of at all). Did you check the systemd journal? Aug 25, 2020 at 19:42
  • I have edited my answer with the output of journal -xe | grep CRON
    – printf
    Aug 26, 2020 at 13:40

1 Answer 1

-1

It seems you're using the wrong tool for the job here; instead of cron, you could put a script in /etc/init.d. If you're on Debian, you can find some help at /etc/init.d/README.

2
  • im on Arch Linux
    – printf
    Aug 26, 2020 at 13:32
  • -1 OP uses systemd, not System V. Aug 26, 2020 at 14:59

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.