Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
feh script refusing to work with crontab [SOLVED}
#1
Linux Mint 19.3
Cinnamon 4.4.8

Hi,
I've written a basic script which enables feh to select a randomized wallpaper, which works when I run it manually. The file is executable, owned by myself, has permissions 764 (also tried 777), and is located in ~/bin

Code:
feh -z --bg-scale ~/pictures/Wallpapers/
 
However, I can't get it to run at start up using crontab, which is set as:
Code:
@reboot sleep 30 && /path/to/file &


I've tried increment delays up to 60s, as well as no delay. I've toggled between running it in the background with and without '&', and I've also tired this variation:

Code:
@reboot sleep 30; /path/to/file &


Finally, I've tried running it as sudo crontab, which hasn't worked either. I'm sure it's an easy fix, but I'm all out of ideas. Can anyone help me out, please?
Reply
#2
Try looking at the log of the cron daemon. If I remember correctly, you can view it with the following command:

Code:
journalctl -u cronie.service

To scroll to the bottom, press 'G' (capital g).
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#3
(02-03-2020, 04:24 PM)leon.p Wrote: Try looking at the log of the cron daemon. If I remember correctly, you can view it with the following command:

Code:
journalctl -u cronie.service

To scroll to the bottom, press 'G' (capital g).

It says: --No entries--
Reply
#4
(02-03-2020, 06:07 PM)Huxley Wrote: It says: --No entries--


This means that either your cron daemon is not enabled or that the service is named differently on your distribution.

The following command will list all services containing the word "cron":

Code:
systemctl list-units | grep -ia cron

For me it finds "cronie.service" and tells me that it is "loaded", "active" and "running".

You can try the first command (the "journalctl" one) again on whatever service it finds for you.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#5
(02-03-2020, 09:19 PM)leon.p Wrote:
(02-03-2020, 06:07 PM)Huxley Wrote: It says: --No entries--


This means that either your cron daemon is not enabled or that the service is named differently on your distribution.

The following command will list all services containing the word "cron":

Code:
systemctl list-units | grep -ia cron

For me it finds "cronie.service" and tells me that it is "loaded", "active" and "running".

You can try the first command (the "journalctl" one) again on whatever service it finds for you.

I ran that search, and got this back:
Code:
cron.service        loaded active running   Regular background program processing daemon                                    
anacron.timer       loaded active waiting   Trigger anacron every hour
Reply
#6
(02-03-2020, 11:00 PM)Huxley Wrote: I ran that search, and got this back:
Code:
cron.service        loaded active running   Regular background program processing daemon                                    
anacron.timer       loaded active waiting   Trigger anacron every hour

That is exactly what we want.

Now we know what the name of the cron service is, which is needed for viewing its logs:

Code:
journalctl -u cron.service

Again just press capital G to scroll all the way to the bottom.
My website - My git repos

"Things are only impossible until they’re not." - Captain Jean-Luc Picard
Reply
#7
(02-04-2020, 04:40 PM)leon.p Wrote:
(02-03-2020, 11:00 PM)Huxley Wrote: I ran that search, and got this back:
Code:
cron.service        loaded active running   Regular background program processing daemon                                    
anacron.timer       loaded active waiting   Trigger anacron every hour

That is exactly what we want.

Now we know what the name of the cron service is, which is needed for viewing its logs:

Code:
journalctl -u cron.service

Again just press capital G to scroll all the way to the bottom.

Here it is:

Code:
journalctl -u cron.service
Feb 04 11:38:34 linux systemd[1]: Started Regular background program processing daemon.
Feb 04 11:38:34 linux cron[916]: (CRON) INFO (pidfile fd = 3)
Feb 04 11:38:34 linux cron[916]: (CRON) INFO (Running @reboot jobs)
Feb 04 11:38:34 linux CRON[923]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 11:38:34 linux CRON[933]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 11:38:34 linux CRON[922]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:38:34 linux CRON[967]: (aaron) CMD (~/bin/papes.sh &)
Feb 04 11:38:34 linux CRON[922]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:38:44 linux CRON[923]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:38:44 linux CRON[923]: pam_unix(cron:session): session closed for user root
Feb 04 11:43:01 linux cron[916]: (aaron) RELOAD (crontabs/aaron)
Feb 04 11:44:46 linux systemd[1]: Stopping Regular background program processing daemon...
Feb 04 11:44:46 linux systemd[1]: Stopped Regular background program processing daemon.
-- Reboot --
Feb 04 11:45:15 linux systemd[1]: Started Regular background program processing daemon.
Feb 04 11:45:15 linux cron[949]: (CRON) INFO (pidfile fd = 3)
Feb 04 11:45:15 linux cron[949]: (CRON) INFO (Running @reboot jobs)
Feb 04 11:45:15 linux CRON[958]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:45:15 linux CRON[957]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:45:15 linux CRON[959]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 11:45:15 linux CRON[968]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 11:45:15 linux CRON[985]: (aaron) CMD (who -b >> /home/user_name/boot.log)
Feb 04 11:45:15 linux CRON[986]: (aaron) CMD (~/bin/papes.sh &)
Feb 04 11:45:15 linux CRON[957]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:45:15 linux CRON[957]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:45:15 linux CRON[958]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:45:25 linux CRON[959]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:45:25 linux CRON[959]: pam_unix(cron:session): session closed for user root
Feb 04 11:49:30 linux systemd[1]: Stopping Regular background program processing daemon...
Feb 04 11:49:30 linux systemd[1]: Stopped Regular background program processing daemon.
-- Reboot --
Feb 04 11:49:59 linux cron[943]: (CRON) INFO (pidfile fd = 3)
Feb 04 11:49:59 linux systemd[1]: Started Regular background program processing daemon.
Feb 04 11:49:59 linux cron[943]: (CRON) INFO (Running @reboot jobs)
Feb 04 11:49:59 linux CRON[953]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:49:59 linux CRON[956]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:49:59 linux CRON[966]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:49:59 linux CRON[953]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:50:09 linux CRON[956]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:50:09 linux CRON[956]: pam_unix(cron:session): session closed for user root
Feb 04 12:03:23 linux systemd[1]: Stopping Regular background program processing daemon...
Feb 04 12:03:23 linux systemd[1]: Stopped Regular background program processing daemon.
-- Reboot --
Feb 04 12:03:52 linux cron[902]: (CRON) INFO (pidfile fd = 3)
Feb 04 12:03:52 linux cron[902]: (CRON) INFO (Running @reboot jobs)
Feb 04 12:03:52 linux systemd[1]: Started Regular background program processing daemon.
Feb 04 12:03:52 linux CRON[910]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 12:03:52 linux CRON[909]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 12:03:52 linux CRON[911]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 12:03:52 linux CRON[937]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 12:03:52 linux CRON[961]: (aaron) CMD (who -b >> /home/aaron/boot.log)
Feb 04 12:03:52 linux CRON[910]: pam_unix(cron:session): session closed for user aaron
Feb 04 12:03:52 linux CRON[909]: pam_unix(cron:session): session closed for user aaron
Feb 04 12:04:02 linux CRON[911]: (CRON) info (No MTA installed, discarding output)
Feb 04 12:04:02 linux CRON[911]: pam_unix(cron:session): session closed for user root
...skipping...
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:49:59 linux CRON[966]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:49:59 linux CRON[953]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:50:09 linux CRON[956]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:50:09 linux CRON[956]: pam_unix(cron:session): session closed for user root
Feb 04 12:03:23 linux systemd[1]: Stopping Regular background program processing daemon...
Feb 04 12:03:23 linux systemd[1]: Stopped Regular background program processing daemon.
-- Reboot --
Feb 04 12:03:52 linux cron[902]: (CRON) INFO (pidfile fd = 3)
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 11:49:59 linux CRON[966]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 11:49:59 linux CRON[955]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:49:59 linux CRON[953]: pam_unix(cron:session): session closed for user aaron
Feb 04 11:50:09 linux CRON[956]: (CRON) info (No MTA installed, discarding output)
Feb 04 11:50:09 linux CRON[956]: pam_unix(cron:session): session closed for user root
Feb 04 12:03:23 linux systemd[1]: Stopping Regular background program processing daemon...
Feb 04 12:03:23 linux systemd[1]: Stopped Regular background program processing daemon.
-- Reboot --
Feb 04 12:03:52 linux cron[902]: (CRON) INFO (pidfile fd = 3)
Feb 04 12:03:52 linux cron[902]: (CRON) INFO (Running @reboot jobs)
Feb 04 12:03:52 linux systemd[1]: Started Regular background program processing daemon.
Feb 04 12:03:52 linux CRON[910]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 12:03:52 linux CRON[909]: pam_unix(cron:session): session opened for user aaron by (uid=0)
Feb 04 12:03:52 linux CRON[911]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 12:03:52 linux CRON[937]: (root) CMD (sleep 10 &&  home/aaron/bin/papes.sh)
Feb 04 12:03:52 linux CRON[961]: (aaron) CMD (who -b >> /home/aaron/boot.log)
Feb 04 12:03:52 linux CRON[910]: pam_unix(cron:session): session closed for user aaron
Feb 04 12:03:52 linux CRON[909]: pam_unix(cron:session): session closed for user aaron
Feb 04 12:04:02 linux CRON[911]: (CRON) info (No MTA installed, discarding output)
Feb 04 12:04:02 linux CRON[911]: pam_unix(cron:session): session closed for user root
Feb 04 12:17:01 linux CRON[2534]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 12:17:01 linux CRON[2534]: pam_unix(cron:session): session closed for user root
Feb 04 13:17:01 linux CRON[3701]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 13:17:01 linux CRON[3701]: pam_unix(cron:session): session closed for user root
Feb 04 14:17:01 linux CRON[4786]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 14:17:01 linux CRON[4786]: pam_unix(cron:session): session closed for user root
Feb 04 15:17:01 linux CRON[5010]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 15:17:01 linux CRON[5011]: (root) CMD (   cd / && run-parts --report /etc/cron.hourly)
Feb 04 15:17:01 linux CRON[5010]: pam_unix(cron:session): session closed for user root
Feb 04 16:17:01 linux CRON[5242]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 16:17:01 linux CRON[5242]: pam_unix(cron:session): session closed for user root
Feb 04 17:17:01 linux CRON[5651]: pam_unix(cron:session): session opened for user root by (uid=0)
Feb 04 17:17:01 linux CRON[5651]: pam_unix(cron:session): session closed for user root
Reply
#8
Turned out that cron doesn't know my environment variables, so I had to define my display monitor in the script.

Code:
export DISPLAY=":0.0"
feh -z --bg-scale ~/pictures/Wallpapers/
 
Everything is now running smoothly.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)