title: pkill isn't fully killing process?
body: <p>I'm doing some testing with <code>flock</code> and <code>pkill</code> for a <code>test.sh</code> script that I'm calling from <code>cron</code> and I ran into something I don't understand.</p>
  
  <p>The <code>test.sh</code> is scheduled as a <code>* * * * *</code> job in cron. Its a very simple script that for testing purposes writes a timestamp to file and then sleeps for 5 minutes. This is to confirm <code>flock</code> is working well and preventing multiple processes for the same script.</p>
  
  <p>This part is working well as I only see one timestamp showing up per 5 minutes despite the <code>test.sh</code> being scheduled to run every minute.</p>
  
  <p>Now as a extra safety measure I want to kill the <code>test.sh</code> (because the script I actually want to use sometimes appears to hang syncing some files to S3 using AWS CLI)</p>
  
  <p>So I figured <code>pkill</code> would be the easiest as it doesn't require modifying anything to my existing script.</p>
  
  <p>If I run <code>pkill -9 -f test.sh</code> it says the processes is killed. Running <code>ps aux | grep test.sh</code> I indeed don't see any <code>test.sh</code> processes anymore.</p>
  
  <p>However as <code>cron</code> is supposed to <code>test.sh</code> every minute, I expect that after killing the process, it would start again after less than a minute.</p>
  
  <p>However it appears that the script doesn't actually restart until the sleep period is over.</p>
  
  <p>So the script initially runs at e.g. <code>12:00</code>, sleep will last until <code>12:05</code>. If I kill the script on <code>12:02</code> I expect it to run again at <code>12:03</code> but it's not actually running again until <code>12:05</code> which is inline with the sleep period.</p>
  
  <p>Why is this happening? Also, if <code>pkill</code> is not recommended, is there any other way to kill my processes after a certain amount of time? Preferably without having to edit the original script.</p>