Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Thu, 25 Sep 2003 12:38:09 -0400 (EDT) From: Igor Pechtchanski Reply-To: cygwin AT cygwin DOT com To: Al Goodniss cc: cygwin AT cygwin DOT com Subject: Re: /etc/profile not being executed by cron job In-Reply-To: <20030925161417.GA3476@townisp.com> Message-ID: References: <20030925161417 DOT GA3476 AT townisp DOT com> Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII On Thu, 25 Sep 2003, Al Goodniss wrote: > Hi, > > Please point me to what I missed. I have a simple cron job doing backups > using tar and find. Works flawlessly in an interactive shell. Cron also > works fine for fetching mail, etc. The combination doesn't work. > > When I run my bash (tcsh also fails) script via Cron the wrong find is > found. Instead of /usr/bin/find I get the windows version. My > /etc/profile does prepend the directories, the permissions seen accurate > - as per the other fixes that were in the archives. > > What did I miss? > > -Al > > --- Test script --- > #!/usr/bin/bash > [snip] The regular invocation of bash is a non-login shell, and thus won't execute /etc/profile. Try changing the #! line to "#!/usr/bin/bash -l". Be aware that you will not be able to use a relative path either to invoke the script or inside the script after that, as /etc/profile does a 'cd "$HOME"'. Alternatively, you can add the following to the top of the script: if ! shopt -q login_shell; then exec -l /bin/bash --login "$PWD/$0" "$PWD" "$@" fi cd "$1" shift The above should work even with relative paths, but I haven't tested it extensively. Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha AT cs DOT nyu DOT edu ZZZzz /,`.-'`' -. ;-;;,_ igor AT watson DOT ibm DOT com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski, Ph.D. '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "I have since come to realize that being between your mentor and his route to the bathroom is a major career booster." -- Patrick Naughton -- Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple Problem reports: http://cygwin.com/problems.html Documentation: http://cygwin.com/docs.html FAQ: http://cygwin.com/faq/