|
|
|
|
|
|
| Author |
Message |
neb9002@gmail.com *nix forums beginner
Joined: 05 May 2006
Posts: 2
|
Posted: Fri May 05, 2006 1:12 am Post subject:
Acces Rights of a backgrounded process
|
|
|
Hello,
I am using a perl script to check for the existence of a process every
5 seconds and under specific circumstances kill the process identified.
The script is launched as root and backgrounded from rc.local.
It is capable of performing all actions (e.g. read/write files etc)
with root privileges except from actually killing another process.
I believe that I have also ruled out any specific perl related issue by
implementing a similar shell script. It suffers from the very same
problem.
Can anybody suggest what the issue might be?
I understand that the "mode" of a script running from rc is different
to one launched from a command line (which incidentally works fine for
both perl and shell scripts).
Thanks in advance....
H. |
|
| Back to top |
|
 |
DoN. Nichols *nix forums beginner
Joined: 20 Feb 2005
Posts: 33
|
Posted: Fri May 05, 2006 3:18 am Post subject:
Re: Acces Rights of a backgrounded process
|
|
|
According to <neb9002@gmail.com>:
| Quote: | Hello,
I am using a perl script to check for the existence of a process every
5 seconds and under specific circumstances kill the process identified.
The script is launched as root and backgrounded from rc.local.
It is capable of performing all actions (e.g. read/write files etc)
with root privileges except from actually killing another process.
I believe that I have also ruled out any specific perl related issue by
implementing a similar shell script. It suffers from the very same
problem.
Can anybody suggest what the issue might be?
|
Well ... with the shell script, I consider it possible that you
are invoking a program which is not on the very limited PATH which cron
passes to scripts. The safest work-around is to include the entire path
to each command in the script -- usually by doing something like:
KILL=/bin/kill
and invoking it as
$KILL
in the script.
I'm not sure whether you are invoking anything external from
your perl script, but if so, it may have similar problem.
A quick test of the cron on an OBSD 3.4 system shows the value
of the PATH environment variable to be:
/bin:/sbin:/usr/bin:/usr/sbin
so any program which is not to be found along that path will fail to
execute. Personally, I prefer having *every* program in a script
executed from the crontab entered as a complete path -- especially ones
run as root, so there is less chance of executing somebody's program of
the same name, which may be intended to do things which you would not
like to have done. :-)
| Quote: | I understand that the "mode" of a script running from rc is different
to one launched from a command line (which incidentally works fine for
both perl and shell scripts).
|
The first difference is the PATH environment variable. Start a
sub-shell, set the path to what cron uses, and see if your script still
works.
If it does, then the problem may be instead access to libraries
which your programs depend upon. Try ldd to see what libraries all of
the programs need. You may need to set LOAD_LIBRARY_PATH in the script
to assure that you have everything which you need.
For that matter -- I'll bet that your perl script depends on a
bunch of perl functions -- and that is not in the path, either.
Try to make it work from cron as a shell script first -- once
that is working, see what you can do to make it work with perl.
Good Luck,
DoN.
--
Email: <dnichols@d-and-d.com> | Voice (all times): (703) 938-4564
(too) near Washington D.C. | http://www.d-and-d.com/dnichols/DoN.html
--- Black Holes are where God is dividing by zero --- |
|
| Back to top |
|
 |
neb9002@gmail.com *nix forums beginner
Joined: 05 May 2006
Posts: 2
|
Posted: Fri May 05, 2006 11:26 pm Post subject:
Re: Acces Rights of a backgrounded process
|
|
|
Hello,
Thanks for your efforts, they were atually fruitfull in an unexpected
way.
I failed to say before that I did try giving the full path to commands
I used and there were no errors in the perl script for modules not
being found.
However, I did look into the special case when a script/shell is
launched from the rc scripts and more psecifically how it affects the
enviroment variables and shell options.
It turns out that the problem was that the width of terminal set by
default was so narrow that the fields I was filtering on were not
there!
Instead of changing configs for the shell, I simply used a 'ps -axo
user,pid,command' which allows for all the data to be presented and
everything worked fine!
Thanks again for your effort
H. |
|
| Back to top |
|
 |
DoN. Nichols *nix forums beginner
Joined: 20 Feb 2005
Posts: 33
|
Posted: Sat May 06, 2006 4:47 am Post subject:
Re: Acces Rights of a backgrounded process
|
|
|
According to <neb9002@gmail.com>:
| Quote: | Hello,
Thanks for your efforts, they were atually fruitfull in an unexpected
way.
|
[ ... ]
| Quote: | Thanks again for your effort
|
I'm glad that you found the solution.
Enjoy,
DoN.
--
Email: <dnichols@d-and-d.com> | Voice (all times): (703) 938-4564
(too) near Washington D.C. | http://www.d-and-d.com/dnichols/DoN.html
--- Black Holes are where God is dividing by zero --- |
|
| Back to top |
|
 |
Google
|
|
| Back to top |
|
 |
|
|
The time now is Sat Jan 10, 2009 4:13 am | All times are GMT
|
|
Debt Consolidation | Debt Consolidation | Credit Reports | Banruptcy | Loans
|
|
Copyright © 2004-2005 DeniX Solutions SRL
|
|
|
|
Other DeniX Solutions sites:
Unix/Linux blog |
electronics forum |
medicine forum |
science forum |
|
|
Privacy Policy
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|