How to use a cron job to open a web page in a browser

At work, I have a set of long-term goals I'm supposed to be making progress on over the year. As a way to remind myself about them, I have a cron job setup to open the URL with the goals on them every morning.

First, you need to create a bash script to open a webpage. Note that I'm setting the display so that when cron runs the job behind the scenes, it knows which display to use. I'm also using xdg-open, which will open a URL (or any document) in the currently registered application. In my case, that's Chrome.

#!/bin/bash
export DISPLAY=:0
xdg-open https://docs.google.com/document/d/some_document_id

I saved this as ~/bin/outcomes.sh. Next, you need to make it executable.

chmod +x ~/bin/outcomes.sh

Finally, you need to schedule it in cron. Here is the syntax for running it every morning at 8AM.

>crontab -e
* 8 * * * /home/chase/bin/outcomes.sh


I'm currently working at NerdWallet, a startup in San Francisco trying to bring clarity to all of life's financial decisions. We're hiring like crazy. Hit me up on Twitter, I would love to talk.

Follow @chase_seibert on Twitter