Yurii Rabeshko
Yurii Rabeshko

Reputation: 631

Crontab runs but nothing happens

I want to simulate a wallpapers slideshow (pictures are fetched from unsplash.com) almost the same as on Windows 7 but on Ubuntu. So for this purpose I decide to use unsplash-wallpaper.

I created a bash script .refresh-wallpaper.sh and placed it to home direcotry:

#!/bin/bash
unsplash-wallpaper -r --dir "~/Pictures/wallpapers"

Then I install a crontab:

SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
* * * * * sh ~/.refresh-wallpaper.sh >/dev/null 2>&1

The script runs by crond but nothing happened:

Dec 17 22:12:01 pcname CRON[11933]: (username) CMD (sh ~/.refresh-wallpaper.sh >/dev/null 2>&1)

..but it works when it launched manually via terminal:

username@pcname:~$ sh .refresh-wallpaper.sh 
Request https://source.unsplash.com/random
Downloading [==================================================================]
✔︎ Image saved to /home/username/Pictures/wallpapers/wallpaper-photo-1511620356826-e2ed21a61991.jpg
Check it out.

What I do wrong? Thanks for any interaction!

EDIT1: It works because new images are saved and output redirects to the log but wallpapers doesn't check out on desktop.

Upvotes: 0

Views: 899

Answers (1)

Cyrus
Cyrus

Reputation: 88899

I assume that the quotation marks in your script prevent the expansion of ~ in this line:

unsplash-wallpaper -r --dir "~/Pictures/wallpapers"

I suggest to use:

unsplash-wallpaper -r --dir "$HOME/Pictures/wallpapers"

Upvotes: 1

Related Questions