6

I have a PHP script on server that sends newsletter emails to my site users using a cron job. The users list is approximately 55,000 and takes nine hours.

Is there any way to stop it (urgently)?

3
  • bg; to get the processes runing, kill to it
    – Ibu
    May 16, 2011 at 4:49
  • Please describe how do i kill this?
    – Sohail
    May 16, 2011 at 4:52
  • 3
    ps -e will give you the list of process, and kill processid (processid is a number)
    – Ibu
    May 16, 2011 at 4:54

4 Answers 4

4

http://unix.derkeiler.com/Newsgroups/comp.unix.admin/2006-09/msg00132.html

http://unix.ittoolbox.com/groups/technical-functional/shellscript-l/how-to-kill-the-cronjob-which-is-running-currently-477250

You need to get the PID of your running cron job and then perform simple kill command.

3
  • Cron job script file is on host server. I have cPanel only. how do i check all processes by ps -e command?
    – Sohail
    May 16, 2011 at 5:06
  • 1
    If you don't have any kind of SSH access to command terminal, you can't do that.
    – Tomasz Kowalczyk
    May 16, 2011 at 5:07
  • You may use the system command to exec something from your php script and see the output. May 16, 2011 at 11:04
2

I wouldn't suggest allowing the use of system(), exec(), passthru(), etc. Its a security issue.

If you do have a control panel, there has to be a way to manage the cron jobs, and I believe with most of them you also have the ability to launch an SSH session. You could use this method to stop/start the running process.

Last but not least, if you can't stop it yourself, contact your host.

2

someone already wrote u the answer,

try:

  1. ps -e | grep "php name file"

    the above command will display you the process id, so:

  2. kill - 9 'process ID'

    : )

1

Just comment out the specific cron job you want to not run. Switch to the user that controls the task, export your editor of choice into the environment, then use crontab -l:

$ su - root
...
# EDITOR=vi; export EDITOR
# crontab -l

If you are using cPanel. GO to Advance section of the Corn Job and click the Delete button.

If the delete button is not there, switch cPanel skin to 'X' to view the Delete button.

1
  • 2
    Either you didn't read the question or you failed to understand it. The OP is asking how to stop an already running cron job, not how to edit it. May 25, 2011 at 4:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .