Geek Lair

bash and cron

leave a comment »

Setting up cron in Ubuntu is simple enough as described in the Ubuntu wiki. But what they don’t mention is that by default cron uses /bin/sh for its SHELL env variable. That may cause a problem if you try to set up a bash script in cron. To prevent that from happening, you need to define the SHELL variable for your user crontab to point to /bin/bash.

In the console type:

crontab -e

Add the following line at the top:

SHELL=/bin/bash

Your crontab should look something like this:

SHELL=/bin/bash
# m h  dom mon dow   command
*/5 * * * * /usr/local/bin/my_bash_script

Advertisements

Written by anonir

October 13, 2009 at 15:45

Posted in bash, Linux, Ubuntu

Tagged with ,

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: