DEV Community

Discussion on: September 3rd, 2020: What did you learn this week?

Collapse
 
vonheikemen profile image
Heiker

I learned about anacron, cron's companion. Just like cron you can use it to schedule some task but the difference is it doesn't assume your system is running 24/7. This is from the manpage.

For each job, Anacron checks whether this job has been executed in the last n days, where n is the period specified for that job. If not, Anacron runs the job's shell command, after waiting for the number of minutes specified as the delay parameter.

This nice article can tell you more about it.

I also learned that scripts executed by cron and anacron are a horrible environment for GUI apps. If you do want to show something on the screen your best chance is to run it with your user (not as root) and set the DISPLAY variable in the script. I do something like this.

runuser -u my-user-name /path/to/my/executable/script
Collapse
 
nickytonline profile image
Nick Taylor

That's awesome! 🔥

Yes, that's awesome!