I ran a Unix script to send me and my friend emails every few seconds to test mailx. The stupid thing is I used $ while true; do blah blah blah...; and as far as I can tell, it has not stopped running because I kept getting emails long after I killed the process and deleted the file – or so it would seem at least.

The flow of emails suddenly stopped at some point, but that's simply because we believe gmail gave up on our accounts or something. We sent regular emails to ourselves, and we haven't received anything for the past few hours. No, there's nothing new in the Spam box either.

  • Did you kill the process that was doing this? ps -eaf and look for your script still running in memory. You can delete the file, but have the script loaded in memory, still chugging away. – slm Feb 27 '14 at 5:42
  • try sudo pkill -9 blah – Red Cricket Feb 27 '14 at 6:13
  • another complicating factor is that I'm at college, so I'm running this on my CS department's virtual machine. In other words, I cannot sudo. And there is a lot of noise I must sort through. But whenever I use ps -ef | grep [my username], I only see some basic commands that are automatically running and none pertaining to the scripts I was running – user61466 Feb 27 '14 at 6:59
  • FYI ps -ef | grep username is comparable to ps -fu username – roaima Jun 2 '15 at 20:50
  • @RedCricket sudo pkill -9 blah does not help - blah is the program that is restarted in a close loop. He needs to call the script that contains the loop: pkill -9 send_email_script_with_blah. – Volker Siegel Sep 1 '18 at 13:19

If you killed the process with something like "kill -9" and "ps -eaf | grep" command does not show your process anymore, then it is dead. The problem may come from somewhere else. What I understand is that you still received emails once the process had been killed, and at some point, nothing happened anymore.

As you had an infinite loop, it may come from the email server that had to send a lot of emails in a very short time. It may have thus taken some time to send these emails, and for your gmail account to receive them, which may have created this "delay" in the reception even after the process was killed. This is a simple explanation, but with your problem description, it seems fair.

PS: if your script has a log file, you can check it to see if it's still growing and if you received the same number of emails sent.

PPS: you can also test, now, a new script to send the same email to you, only once. If you receive it, then my explanation above may be correct. If you don't receive it, then gmail has blocked the sender/this kind of email and your issue may come from somewhere else.

| improve this answer | |
  • And, if you have a fairly accurate record of when you killed the script and how long you continued to receive messages, you can look closely at the headers of the most recently received messages to see whether they say they were sent before the script was killed. – G-Man Says 'Reinstate Monica' Jun 2 '15 at 19:59
  • Messages are often queued very quickly, but if thousands of them are queued in a short timespan, the mailer software often does not send them all at once, but in batches of some size. I.e., the sending of one or several emails is an asynchronous process. – Kusalananda Sep 1 '18 at 13:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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