differences between service command and running command directly
Hi All,
I use service and running the command in /etc/init.d/ directly to run the
services in that directory. Until now I thought it was the same to run, for
example:
service httpd status
and
/etc/init.d/httpd status
but now I have a server that they donīt do the same:
#/etc/init.d/httpd status
httpd is stopped
and
#service httpd status
httpd (pid 23784) is running
Anyone can explain me this? I suposse itīs something about enviroment
variables, but I canīt see the difference
Thanks in advance,
ESG
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 12:28 PM
Barry Brimer
differences between service command and running command directly
I use service and running the command in /etc/init.d/ directly to run the
services in that directory. Until now I thought it was the same to run, for
example:
service httpd status
and
/etc/init.d/httpd status
but now I have a server that they donīt do the same:
<snip>
Anyone can explain me this? I suposse itīs something about enviroment
variables, but I canīt see the difference
I would run both with bash -x and redirect the output and compare or diff
them.
bash -x service httpd status >/tmp/service.log 2>&1
bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
Barry--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 02:52 PM
ESGLinux
differences between service command and running command directly
Hi Barry,
very good your idea, !!!
The output are very very very different,
Iīm going to analize it, and Iīll publish the results....
Thanks,
ESG
2011/10/4 Barry Brimer <lists@brimer.org>
> I use service and running the command in /etc/init.d/ directly to run the
>> services in that directory. Until now I thought it was the same to run,
>> for
>> example:
>>
>> service httpd status
>>
>> and
>>
>> /etc/init.d/httpd status
>>
>> but now I have a server that they donīt do the same:
>>
>
> <snip>
>
>
> Anyone can explain me this? I suposse itīs something about enviroment
>> variables, but I canīt see the difference
>>
>
> I would run both with bash -x and redirect the output and compare or diff
> them.
>
> bash -x service httpd status >/tmp/service.log 2>&1
>
> bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
>
> Barry
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 03:22 PM
ESGLinux
differences between service command and running command directly
Hi again,
Very very strange.
The service command executes:
env -i LANG=es_ES.UTF-8 PATH=/sbin:/usr/sbin:/bin:/usr/bin TERM=xterm
/etc/init.d/httpd status
If I run this command from the shell, it runs ok, but If I donīt
give LANG=es_ES.UTF-8 I get the error.
Iīm going to continue investigating...
Greetings,
ESG
2011/10/4 ESGLinux <esggrupos@gmail.com>
> Hi Barry,
>
> very good your idea, !!!
>
> The output are very very very different,
>
> Iīm going to analize it, and Iīll publish the results....
>
> Thanks,
>
> ESG
>
>
>
> 2011/10/4 Barry Brimer <lists@brimer.org>
>
>> I use service and running the command in /etc/init.d/ directly to run
>>> the
>>> services in that directory. Until now I thought it was the same to run,
>>> for
>>> example:
>>>
>>> service httpd status
>>>
>>> and
>>>
>>> /etc/init.d/httpd status
>>>
>>> but now I have a server that they donīt do the same:
>>>
>>
>> <snip>
>>
>>
>> Anyone can explain me this? I suposse itīs something about enviroment
>>> variables, but I canīt see the difference
>>>
>>
>> I would run both with bash -x and redirect the output and compare or diff
>> them.
>>
>> bash -x service httpd status >/tmp/service.log 2>&1
>>
>> bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
>>
>> Barry
>> --
>> redhat-list mailing list
>> unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
>> https://www.redhat.com/mailman/listinfo/redhat-list
>>
>
>
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 03:41 PM
Daniel Carrillo
differences between service command and running command directly
2011/10/4 Barry Brimer <lists@brimer.org>:
>> I use service and running the command in /etc/init.d/ directly *to run the
>> services in that directory. Until now I thought it was the same to run,
>> for
>> example:
>>
>> service httpd status
>>
>> and
>>
>> /etc/init.d/httpd status
>>
>> but now I have a server that they donīt do the same:
>
> <snip>
>
>> Anyone can explain me this? I suposse itīs something about enviroment
>> variables, but I canīt see the difference
>
> I would run both with bash -x and redirect the output and compare or diff
> them.
>
> bash -x service httpd status >/tmp/service.log 2>&1
>
> bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
IMHO: This has no sense, because service is only a wrapper who calls
to /etc/init.d/xservice
man service
service runs a System V init script in as predictable environment as
possible, removing most environment variables and with current working
directory set to /.
Best regrads.
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 04:27 PM
ESGLinux
differences between service command and running command directly
GOTCHA!!!!
I always have read that running services using service command is safer than
using the script directly
the key is that service runs the script with env -i (with an empty
enviroment) so if there is any wrong variable you are protected.
My problem is that in /etc/profile.d/ I have defined a wrong variable and
when I run /etc/init.d/httpd status the scripts runs with the corrupt
enviroment.
with service you allways run with an empty enviroment so I donīt get the
error.
Thank you all for your help. I hope it gives a bit of light about it ;-)
ESG
2011/10/4 Daniel Carrillo <daniel.carrillo@gmail.com>
> 2011/10/4 Barry Brimer <lists@brimer.org>:
> >> I use service and running the command in /etc/init.d/ directly to run
> the
> >> services in that directory. Until now I thought it was the same to run,
> >> for
> >> example:
> >>
> >> service httpd status
> >>
> >> and
> >>
> >> /etc/init.d/httpd status
> >>
> >> but now I have a server that they donīt do the same:
> >
> > <snip>
> >
> >> Anyone can explain me this? I suposse itīs something about enviroment
> >> variables, but I canīt see the difference
> >
> > I would run both with bash -x and redirect the output and compare or diff
> > them.
> >
> > bash -x service httpd status >/tmp/service.log 2>&1
> >
> > bash -x /etc/init.d/httpd status >/tmp/initscript.log 2>&1
>
> IMHO: This has no sense, because service is only a wrapper who calls
> to /etc/init.d/xservice
>
> man service
>
> service runs a System V init script in as predictable environment as
> possible, removing most environment variables and with current working
> directory set to /.
>
> Best regrads.
>
> --
> redhat-list mailing list
> unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
> https://www.redhat.com/mailman/listinfo/redhat-list
>
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-04-2011, 05:19 PM
differences between service command and running command directly
ESGLinux wrote:
> GOTCHA!!!!
>
> I always have read that running services using service command is safer
> than using the script directly
>
> the key is that service runs the script with env -i (with an empty
> enviroment) so if there is any wrong variable you are protected.
>
> My problem is that in /etc/profile.d/ I have defined a wrong variable and
> when I run /etc/init.d/httpd status the scripts runs with the corrupt
> enviroment.
<snip>
Good catch!
mark
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list
10-05-2011, 04:07 PM
"Greaser, Tom"
differences between service command and running command directly
Thanks for the follow up .. nice to know what you found out!!
--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@redhat.com?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list