# Cron Jobs

### A Quick How To Reference

Cron is used for scheduling repetitive tasks, such as backing up your system once a day, or changing your wallpaper with a new random image every 10 minutes.

You put the commands you want to execute into a text file, save it, and then make that text file executable.

Then you add a line to the crontab file by typing "crontab -e" into a terminal, and adding a line to schedule that script file using the syntax below:

```

# ┌─minute(0-59)

# │ ┌─hour(0-23)

# │ │ ┌─dayOfMonth

# │ │ │ (1 - 31)

# │ │ │ ┌─month(1-12)

# │ │ │ │ ┌─dayOfWeek

# │ │ │ │ │ (0 - 6)

# │ │ │ │ │ (SunToSat;

# │ │ │ │ │ 7 is also

# │ │ │ │ │ SunOnSome

# │ │ │ │ │ systems)

# │ │ │ │ │

* * * * *

```

- "*" means every single one

- "*/10" means every 10

- "*/5" means every 5

So if you put */5 in the minutes place, it means every 5 minutes.

For more info go to [Linux Handbook](https://linuxhandbook.com/crontab) and [KVZ.IO](https://kvz.io/schedule-tasks-on-linux-using-crontab.html).

See comments for some examples.

[⚡️ Follow Freedom Tech](https://nostr.at/npub1fkluklzamwpyn7w8awxzrcqe7z8mldlvthk4gz9kz3vsh6udz62s9qj48l)

#CronJobs #Crontab #Linux #GreedomTech

Reply to this note

Please Login to reply.

Discussion

# Use Cronjobs

### To Set Random Wallpaper from UnSplash

To get a random pictures from UnSplash using keywords, and then set the pictures as wallpapers in Cinnamon or Mate, you can use a script file, and call it with crontab.

Here are the [steps from this website](https://youness.net/linux/set-random-wallpapers-unsplash-com-ubuntu) explaining how:

### In Gnome Desktop

```

#!/bin/bash

wget -O /tmp/wallpaper.jpg https://source.unsplash.com/random

gsettings set org.gnome.desktop.background picture-uri file:///tmp/wallpaper.jpg

```

1. Create a script with above code (I’m doing it in /bin folder):

```

cd /bin

sudo nano unsplash.sh

```

2. Ctrl+X, then Y, then Enter, to save the script.

3. Make it executable, and run it:

```

sudo chmod +x unsplash.sh

./unsplash.sh

```

5. Type this command:

```

crontab -e

```

6. Add this line to run script every 5 mins.:

```

*/5 * * * * /bin/unsplash.sh

```

7. Restart cron

```

sudo service cron reload

```

### For Cinnamon Desktop

In addition to what the website says, modify the unsplash.sh like this to get smooth wallpaper transition:

(Replace **`water,nature`** with your own keywords)

```

#!/bin/bash

wget -O /var/tmp/wallpaper-temp.jpg https://source.unsplash.com/1920x1080/?water,nature

mv /var/tmp/wallpaper-temp.jpg /var/tmp/wallpaper.jpg

gconftool set org.cinnamon.desktop.background picture-uri 'file:///var/tmp/wallpaper.jpg'

```

### For Mate Desktop

Use this command in the script instead of the Cinnamon command above:

```

settings set org.mate.background picture-file '/var/tmp/wallpaper.jpg'

```

[⚡️ Follow Freedom Tech](https://nostr.at/npub1fkluklzamwpyn7w8awxzrcqe7z8mldlvthk4gz9kz3vsh6udz62s9qj48l)

#CronJob #RandomWallpaper #CinnamonDesktop #MateDesktop

#Linux #FreedomTech