0

Using Debian Jessie, I'm having trouble running a one line file I placed in /etc/cron.d

The file contains the following line:

@reboot myuser /usr/bin/keepass2 /home/myuser/mydb.kdbx -pw:password

It is meant to open my keepass database, logged in and to be run as myuser rather than root.

I found this question here which seems to be exactly my problem. As per comments to this answer I changed permissions of the file in cron.d to the following:

-r-----r-- 1 root root 73 Jun 12 09:26 keepass

However it still doesn't seem to work. run-parts --test /etc/cron.d returns an empty line. And it doesn't run at startup either.

pandita
  • 108
  • 9
  • Are you sure you want this to run at boot? This means it won't have a GUI to run in. It would be better to run it as part of ubuntu startup wouldn't it? – Paul Jun 12 '15 at 01:13
  • Hi @Paul, my main aim is to give iceweasel access to the keepass database on startup. I'm not overly familiar with linux... where would be the appropriate place to add this line? Cheers – pandita Jun 15 '15 at 06:44
  • For some reason I thought it was Ubuntu - what desktop environment, gnome, kde or something else? – Paul Jun 15 '15 at 06:48
  • No worries, I'm on gnome – pandita Jun 15 '15 at 06:54
  • I am out of touch with Gnome, try this: https://gnomeshell.wordpress.com/2011/08/28/manage-the-startup-applications/ – Paul Jun 15 '15 at 06:57
  • This looks promising, thanks for that, will try this later on at home – pandita Jun 15 '15 at 07:05

1 Answers1

0

Your problem lies in the fact that keepass is a graphic utility, and using cron to start it at boot does not guarantee that your WM has started yet.

The way to deal with this is to use kpcli, a keepass CLI utility available also on Debian (just checked). It has many available commands, but the one you need is:

   kpcli open file.kdb file.key &

Alternatively, you may start keepass as the very last command at boot, by placing the keepass startup command as the last line (except for the exit 0) in /etc/rc.local.

MariusMatutiae
  • 46,990
  • 12
  • 80
  • 129