need help - user permissions / cron

This is a discussion on need help - user permissions / cron within the Linux Administration forums, part of the Linux Forums category; Hello, Newbie needs help resolving user permissions and automation RH Linux 8.0. Apache Perl 5.8.1 mysql Ver ...


Go Back   Usenet Forums > Linux Forums > Linux Administration

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2004
Chris Fortune
 
Posts: n/a
Default need help - user permissions / cron

Hello,

Newbie needs help resolving user permissions and automation

RH Linux 8.0.
Apache
Perl 5.8.1
mysql Ver 12.22
bogofilter 0.15.7
ClamAV 0.65

Problem: When I run a perl script from cron, the calls to bogofilter and
clamav don't work.

When I run perl script from web (cgi), they work very well, also, they work
from the command line when I execute the script manually.

Thanks


Reply With Quote
  #2 (permalink)  
Old 04-21-2004
Chris Fortune
 
Posts: n/a
Default Re: need help - user permissions / cron

More info:

The perl script pop-forwards an email, writes it to a temporary file (on a
RAM disk), then passes the file on the command line to bogofilter and clamav
using `backtick operators`. Works fine via command line or cgi web, but not
with cron.

??




"Chris Fortune" <cfortune@IDONTLIKESPAMtelus.net> wrote in message
news:LXghc.61211$dg7.59814@edtnps84...
> Hello,
>
> Newbie needs help resolving user permissions and automation
>
> RH Linux 8.0.
> Apache
> Perl 5.8.1
> mysql Ver 12.22
> bogofilter 0.15.7
> ClamAV 0.65
>
> Problem: When I run a perl script from cron, the calls to bogofilter and
> clamav don't work.
>
> When I run perl script from web (cgi), they work very well, also, they

work
> from the command line when I execute the script manually.
>
> Thanks
>
>



Reply With Quote
  #3 (permalink)  
Old 04-21-2004
Bit Twister
 
Posts: n/a
Default Re: need help - user permissions / cron

On Wed, 21 Apr 2004 02:36:34 GMT, Chris Fortune wrote:
> More info:
>
> The perl script pop-forwards an email, writes it to a temporary file (on a
> RAM disk), then passes the file on the command line to bogofilter and clamav
> using `backtick operators`. Works fine via command line or cgi web, but not
> with cron.


add a path statement to all executables.
Put a status check after each command and echo fault to a file to see
where it fails.

Please read http://www.catb.org/~esr/faqs/smart-questions.html
Show us the code.
Reply With Quote
  #4 (permalink)  
Old 04-21-2004
Rich Gibbs
 
Posts: n/a
Default Re: need help - user permissions / cron

Chris Fortune said the following, on 04/20/04 22:36:
> More info:
>
> The perl script pop-forwards an email, writes it to a temporary file (on a
> RAM disk), then passes the file on the command line to bogofilter and clamav
> using `backtick operators`. Works fine via command line or cgi web, but not
> with cron.
>
> ??
>
>


Suggestions:

1. Specify commands (e.g., 'bogofilter') with the full path name.

2. Check the man pages for cron and crontab for your system, to make
sure you understand the "initial conditions" (such as $PATH and other
environment variables) when cron starts your script. I suspect you will
find that you need to explicitly set something that is normally set in
an initialization file.


--
Rich Gibbs
rgibbs@his.com
Reply With Quote
  #5 (permalink)  
Old 04-21-2004
Chris Fortune
 
Posts: n/a
Default Re: need help - user permissions / cron - solution

Thanks for heading me in the right direction!

I did a simple experiment
# crontab -e
*/1 * * * * echo $PATH > cronpath.test.txt

one minute later here was the contents of cronpath.test.txt:
/sbin:/usr/sbin
# rather limited, eh?

the path to bogofilter and clamav is /usr/local/bin, hmmmmm.

# echo $PATH
#
/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/
bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin

so added this line to crontab, explicitly
PATH=/usr/local/jdk/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:
/usr/bin:/usr/X11R6/bin:/usr/local/bin:/usr/X11R6/bin:/root/bin

http://howtos.linuxbroker.com/Path.html#ss10.1




"Rich Gibbs" <rgibbs@REMOVEhis.com> wrote in message
news:4085f323@news101.his.com...
> Chris Fortune said the following, on 04/20/04 22:36:
> > More info:
> >
> > The perl script pop-forwards an email, writes it to a temporary file (on

a
> > RAM disk), then passes the file on the command line to bogofilter and

clamav
> > using `backtick operators`. Works fine via command line or cgi web, but

not
> > with cron.
> >
> > ??
> >
> >

>
> Suggestions:
>
> 1. Specify commands (e.g., 'bogofilter') with the full path name.
>
> 2. Check the man pages for cron and crontab for your system, to make
> sure you understand the "initial conditions" (such as $PATH and other
> environment variables) when cron starts your script. I suspect you will
> find that you need to explicitly set something that is normally set in
> an initialization file.
>
>
> --
> Rich Gibbs
> rgibbs@his.com



Reply With Quote
  #6 (permalink)  
Old 04-21-2004
Rich Gibbs
 
Posts: n/a
Default Re: need help - user permissions / cron - solution

Chris Fortune said the following, on 04/21/04 06:26:
> Thanks for heading me in the right direction!
>
> I did a simple experiment
> # crontab -e
> */1 * * * * echo $PATH > cronpath.test.txt
>
> one minute later here was the contents of cronpath.test.txt:
> /sbin:/usr/sbin
> # rather limited, eh?
>

[SNIP]

Glad to help. On most Unix/Linux systems, 'cron' gives you a pretty
limited initial environment. I think the reasoning (which I agree with)
is that the default facilities for things that run "untouched by human
hands" should be limited, and that it is easy enough to specify any
special requirements.


--
Rich Gibbs
rgibbs@his.com
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0