1

First of all:

This is not a duplicated of Cronjobs made via cronjob not working which seems to be fixed by simply giving execution permissions to the script and/or adding the #!/bin/bash at the beginning of the script.

I have tried some advices published on the net, forums and other but I haven't yet succeeded.

The scenery:

I am experiencing some issues when attempting to run custom scripts located on /usr/bin via cronjob. In example: I am using Ubuntu 14.04.3 with the i3WM Tiling Window Manager, in which I am trying to run a custom script named wall which should change the wallpaper with feh via command line.

The wall script does run well when it is invoked via terminal or the i3wm menu bar, which indicates the script should run, but, it does not.

The script

When I find for the wall script via whereis wall, the terminal shows the next results:

wall: /usr/bin/wall /usr/bin/X11/wall /usr/share/man/man1/wall.1.gz

I am not sure why do I have a copy of the script both on the /usr/bin and the /usr/bin/X11 directories but both them do the same when I run it manually. Neither one or the other do anything when I put it on the crontab.

The script contents is as follows:

feh --bg-scale "`shuf -n1 -e ~/.i3/wall/*`"

This command is going to get a random image from the ~/.i3/wall folder and scale that image to desktop's size in order to be used as a background image.

The script file properties looks like this:

geppettvs@T400:~$ ls /usr/bin -l | grep wall
-rwxr-xr-x 1 root      root       2067448 oct 21  2013 fotowall
-rwxr-xr-x 1 root      root          6264 oct 27 09:21 kwalletd
-rwxr-sr-x 1 root      tty             45 ene 27 07:51 wall
-rwxr-xr-x 1 root      root          1747 abr 25  2014 wallpaper-changer

Of which I just notice the property differs just by the "tty" in the script, which I changed to root via chown with no difference at all.

The crontab

My user's crontab currently contains the next:

GNU nano 2.2.6 File: /tmp/crontab.Fb84OE/crontab                                                                            

# m h  dom mon dow   command
# * * * * * /home/geppettvs/wifirc.sh # JOB_ID_2
* * * * * /usr/bin/wall # JOB_ID_4

My root user crontab looks like this:

# m h  dom mon dow   command

@reboot sudo iwconfig wlan0 rate 54M
* * * * * wall

But, neither the user's crontab or the root one does anything with this script.

Let's have in mind that, this time, I am talking about a simple wallpaper changer script. But I have some other scripts that won't run when I put them in a crontab.

Additional attempts

I have already tried using the #!/bin/bash in the first line of the script, leaving or removing blank lines at the top/bottom of the script and/or the crontab file. And it seems not to have effect to make it work. The same goes for trying to use the absolute path or invoking the script simply by name (which works on a terminal, indeed).

The Log

The Log looks like this:

Feb 13 17:20:01 T400 CRON[9093]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:20:01 T400 CRON[9094]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:21:01 T400 CRON[10290]: (geppettvs) CMD (/usr/bin/wall # JOB_ID_4)
Feb 13 17:21:01 T400 CRON[10291]: (root) CMD (wall)
Feb 13 17:21:01 T400 CRON[10289]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:21:01 T400 CRON[10288]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:22:01 T400 CRON[11575]: (geppettvs) CMD (/usr/bin/wall # JOB_ID_4)
Feb 13 17:22:01 T400 CRON[11578]: (root) CMD (wall)
Feb 13 17:22:01 T400 CRON[11573]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:22:01 T400 CRON[11574]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:23:01 T400 CRON[12860]: (geppettvs) CMD (/usr/bin/wall # JOB_ID_4)
Feb 13 17:23:01 T400 CRON[12862]: (root) CMD (wall)
Feb 13 17:23:01 T400 CRON[12859]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:23:01 T400 CRON[12858]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:24:01 T400 CRON[14157]: (root) CMD (wall)
Feb 13 17:24:01 T400 CRON[14158]: (geppettvs) CMD (/usr/bin/wall # JOB_ID_4)
Feb 13 17:24:01 T400 CRON[14155]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:24:01 T400 CRON[14156]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:25:01 T400 CRON[15448]: (geppettvs) CMD (/usr/bin/wall # JOB_ID_4)
Feb 13 17:25:01 T400 CRON[15450]: (root) CMD (wall)
Feb 13 17:25:01 T400 CRON[15447]: (root) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)
Feb 13 17:25:01 T400 CRON[15446]: (geppettvs) MAIL (mailed 1 byte of output; but got status 0x00ff, #012)

Which seems to be running the script but nothing is happening on each scripts run iteration.

The question

Is it there something wrong I am doing? Or something else I should try?

Any help is appreciated.

Update

As mentioned in a comment for j0h's advice, I have also tried using the absolute path to the image's folder.

The command now looks like

feh --bg-scale "`shuf -n1 -e /home/geppettvs/.i3/wall/*`" 

and it does work on a terminal but doesn't run via cron.

I am guessing the issue comes from the grave accent (`) which can be leading to an interruption in the cronjob's execution.

Nevertheless, I have tried changing the grave accent for another symbol, after which the command stops working everywhere. You can see terminal's output as shown:

geppettvs@T400:~$ feh --bg-scale "'shuf -n1 -e /home/geppettvs/.i3/wall/*'" 
feh WARNING: 'shuf -n1 -e /home/geppettvs/.i3/wall/*' does not exist - skipping
feh: No loadable images specified.
See 'man feh' for detailed usage information

Any help for improving this command is welcome. Thanks in advance.

8
  • 3
    wall is perhaps an unfortunate choice of name for a custom script, since there is already a standard system utility called wall Feb 13, 2016 at 23:31
  • 3
    why is there a "sudo" in your cron?!?!
    – Rinzwind
    Feb 13, 2016 at 23:31
  • @Rinzwind: As I mentioned before, I have tried many things. Including the most ridiculous we can think about. :D Feb 13, 2016 at 23:33
  • @steeldriver I have already changed the name of wall in order to avoid name collisions with no results. The renamed script is now wall-change. My luck should be the worst in the world if there is a standard system utility called wall-change. Thank you for the advice. I didn't notice it before. I appreciate your help. Feb 13, 2016 at 23:37
  • when you run feh --bg-scale "shuf -n1 -e ~/.i3/wall/*" is the tilda your home, or roots? what if you make that Tilda the absolute path you want to specify?
    – j0h
    Feb 14, 2016 at 3:17

0

You must log in to answer this question.

Browse other questions tagged .