* /etc/profile not being executed by cron job
@ 2003-09-25 16:21 Al Goodniss
2003-09-25 16:38 ` Igor Pechtchanski
0 siblings, 1 reply; 3+ messages in thread
From: Al Goodniss @ 2003-09-25 16:21 UTC (permalink / raw)
To: cygwin
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
date
echo $PATH # reports only windows paths, no Cygwin
which find # Finds the win32 version
-- Results --
Thu Sep 25 12:08:00 EST 2003
/c/WINDOWS/system32:/c/WINDOWS:/c/WINDOWS/System32/Wbem:/c/PROGRA~1/ULTRAE~1:/c/Program Files/Micros
oft SQL Server/80/Tools/Binn/:/bin
/c/WINDOWS/system32/find
-- /etc/profile --
PATH="/usr/local/bin:/usr/bin:/bin:$PATH"
export PATH
USER="`id -un`"
# Set up USER's home directory
if [ -z "$HOME" ]; then
HOME="/home/$USER"
fi
if [ ! -d "$HOME" ]; then
mkdir -p "$HOME"
fi
export HOME USER
for i in /etc/profile.d/*.sh ; do
if [ -f $i ]; then
. $i
fi
done
export MAKE_MODE=unix
export PS1='\[\033]0;\w\007 \033[32m\]\u@\h \[\033[33m\w\033[0m\] $ '
cd "$HOME"
--
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: /etc/profile not being executed by cron job
2003-09-25 16:21 /etc/profile not being executed by cron job Al Goodniss
@ 2003-09-25 16:38 ` Igor Pechtchanski
2003-09-26 15:18 ` Al Goodniss
0 siblings, 1 reply; 3+ messages in thread
From: Igor Pechtchanski @ 2003-09-25 16:38 UTC (permalink / raw)
To: Al Goodniss; +Cc: cygwin
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/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: /etc/profile not being executed by cron job
2003-09-25 16:38 ` Igor Pechtchanski
@ 2003-09-26 15:18 ` Al Goodniss
0 siblings, 0 replies; 3+ messages in thread
From: Al Goodniss @ 2003-09-26 15:18 UTC (permalink / raw)
To: cygwin
Thanks Igor.
I followed your adivce and changed the #! line to #!/usr/bin/bash -l and that worked for me. The script I'm using to do backups automatically moves itself around using absolute paths so having profile do that last 'cd "$HOME"' wasn't an issue.
-Al
On Thu, Sep 25, 2003 at 12:38:09PM -0400, Igor Pechtchanski wrote:
> 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/
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2003-09-26 14:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-09-25 16:21 /etc/profile not being executed by cron job Al Goodniss
2003-09-25 16:38 ` Igor Pechtchanski
2003-09-26 15:18 ` Al Goodniss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).