Usually I do like this: kill -9 $(ps aux|grep Firefox|awk '{print($2)}')

But when I try following via cron, it does nothing. 50 * * * * kill -9 $(ps aux|grep Firefox|awk '{print($2)}')

Mind you the process with 'Firefox' that I am trying to kill is also started by some cron.

  • did you add that in /etc/crontab or in your user crontab? – darxmurf Oct 18 '19 at 7:00
  • You say something about an error, but you don't mention what the error is. Also, is there a reason you kill it with the KILL signal, and why you're not using pkill? – Kusalananda Oct 18 '19 at 7:03
  • ignore that part . assume I have always used awk '{print($2)}', ok let me simplify the question. – ishandutta2007 Oct 18 '19 at 7:26
  • @Kusalananda simplified the question for your better understanding. – ishandutta2007 Oct 18 '19 at 7:28
  • It probably kills the actual cron job (since it contains the string Firefox). This is why I asked if there was a reason to not use pkill (which does not have this issue). – Kusalananda Oct 18 '19 at 7:30

Your Answer

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

Browse other questions tagged or ask your own question.