Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have PHP script running right now with root permissions that starts from the following lines:

set_time_limit(0);
ini_set('log_errors', 1);
ini_set('error_log', "log.txt");

It was accidentally started by web management panel from root user as cron task. Right now script is writing warnings caused by something like this while(!feof($file_handle)) to file, increasing its size by 10 megabytes per second.

I don't have console root access to website, server owner is unavailable due to time difference. I only can run commands as root, once per minute, using cron from web panel (no output as you understand).

How can I stop my script from wasting system resources? Right now I delete file every minute with same cron script, so server can continue working. My linux knowledge is not enough to solve this problem without help, unfortunately.

share|improve this question

1 Answer 1

up vote 4 down vote accepted

If the command was executed as something like php /path/to/script.php, then you could do something like

pkill -f /path/to/script.php

or:

kill <pid>

where <pid> is the process id of the process running that you want to kill.

You can also get the pid and executed line of the process with:

pgrep -fl /path/to/script.php

NOTE: the argument to pkill and pgrep should be something you know is in the commandline. The path is usefull if you called it that way, otherwise just use the name.

share|improve this answer
1  
Probably best to use cron to get a process list, identify the pid, then kill it in a subsequent command. To avoid the possibility of any trouble. –  Orbling Feb 1 '11 at 2:10
    
That is what I meant :D. I messed up the order. –  Torian Feb 1 '11 at 2:14
    
You saved my night! Thanks. –  Galichev Anton Feb 1 '11 at 2:18

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.