Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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
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


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
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


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.