From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24977 invoked by alias); 25 Sep 2003 16:38:11 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 24969 invoked from network); 25 Sep 2003 16:38:10 -0000 Received: from unknown (HELO slinky.cs.nyu.edu) (128.122.20.14) by sources.redhat.com with SMTP; 25 Sep 2003 16:38:10 -0000 Received: from slinky.cs.nyu.edu (localhost [127.0.0.1]) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.9) with ESMTP id h8PGcAmL007069; Thu, 25 Sep 2003 12:38:10 -0400 (EDT) Received: from localhost (pechtcha@localhost) by slinky.cs.nyu.edu (8.12.9+Sun/8.12.2/Submit) with ESMTP id h8PGcAwF007066; Thu, 25 Sep 2003 12:38:10 -0400 (EDT) X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs Date: Thu, 25 Sep 2003 16:38:00 -0000 From: Igor Pechtchanski Reply-To: cygwin@cygwin.com To: Al Goodniss cc: cygwin@cygwin.com Subject: Re: /etc/profile not being executed by cron job In-Reply-To: <20030925161417.GA3476@townisp.com> Message-ID: References: <20030925161417.GA3476@townisp.com> Importance: Normal MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2003-09/txt/msg01637.txt.bz2 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@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.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/