Let's automate some tasks on your Raspberry

Active 0 Reply 138 Views 2019-09-23 15:02:31 Raspberry Pi

Get your Raspberry Pi to do stuff automatically with cron

E.g. Open a Web-Browser every day at 7:45

Cron is a piece of software, written for unix systems, that is built into the Raspbian operating system and is used to schedule (automate) tasks to run at different intervals.
Launch Terminal to configure cron
Cron is configured via files called crontabs. Each system user can have own crontabs.

On prompt type: crontab -e (edit crontab).

Usually your crontab already contains some lines that has been commented out using hashes (#) - examples
Scheduling a task: The m (minute), h (hour), dom (date of month), mon(month), dow (day of week). The * means any.

Write a new line: 45 7 * * * export DISPLAY=:0 && chromiumbrowser https://www.fooz.de

This line says at 7:45 on every day of every week in every month, run the command export DISPLAY=0 && chromiumbrowser https://www.fooz.de.

Remark: export DISPLAY=:0 && is required to make sure cron displays the web browser on screen.
Now save your crontab (CTRL+O or CTRL+X) and you are done.

Sharing is caring, show love and share the thread with your friends.

Please Login to reply this topic. If you do not have account, please Register.