Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
464 views
in Technique[技术] by (71.8m points)

linux - How do I end a looping script in crontab?

I'm working on a script that runs through a never ending loop. Using cron I start the script on reboot. However, I need to update this script from github every 24 hours. I'm running a shell script that basically follows:

  1. Backup cron to .txt file
  2. Empty cron with crontab -r
  3. Pull updates from GitHub
  4. Load cron backup and start cron again.

The shell script empties cron, updates the code, then starts cron again with the same file name and cron runs the program again. I'm testing this by outputting a message to a text file every time the script completes one loop. When I change the message output in GitHub, cron pulls the update and I can see the updated message. The problem is, it continues to show the old message as well. For example:

Original Message "Test": Test Test Test Test Test Test Updated Message "Update": Test Update Test Update Test Update

It continues to output old messages even though I cleared cron, updated the code, then started it again. It appears to me that simply emptying cron does not stop the previous loop from continuing to run.

I looked into using "killall" to stop all sh scripts from running, but in an attempt to clear out the many looping scripts I had created I killed every running process with killall5 -9. Now when I enter ps to view running processes, none are listed.

I'm very stuck. Any and all help would be appreciated!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Used sudo pkill python to end all running python scripts.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to WuJiGu Developer Q&A Community for programmer and developer-Open, Learning and Share
...