Quantcast
Channel: Why crontab scripts are not working? - Ask Ubuntu
Viewing all articles
Browse latest Browse all 48

Answer by GrayedFox for Why crontab scripts are not working?

$
0
0

The default .bashrc files on UBuntu 16.04 (and many other versions) have a built in mechanism to not do anything if they are not an interactive shell.

This can prevent the file from being sourced correctly inside a script that is run by cron! To prevent this, comment out the following lines from the top of your .bashrc file:

Ubuntu 16.04

# If not running interactively, don't do anythingcase $- in    *i*) ;;      *) return;;esac

Ubuntu 12.04 and some other versions

# If not running interactively, don't do anything[ -z "$PS1" ] && return

So long as these are left in if cron runs a script which sources your .bashrc file you won't actually get any of the environment variables you are used to inside your terminal!


Viewing all articles
Browse latest Browse all 48

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>