title: Modifying a crontab from a cron job
body: <p>I have a Python script that runs in several modes. One of those modes monitors certain files, and if those files have been modified, the script restores them. The way I do this is to run the script every minute via cron.</p>
  
  <p>Another cron job exists (actually the same script called with a different argument) to remove the script from the crontab when the scheduled time has elapsed. Initially, I was attempting to work with a crontab in <code>/etc/cron.d</code>. The script behaves as expected if executed on the command line, but does not edit the crontab when it is run from cron.</p>
  
  <p>I then switched to writing a temporary file and executing <code>crontab tempfile</code> (via <code>subprocess.Popen</code>) from the script. This doesn't work either, as the crontab is simply not created. Executing <code>crontab tempfile</code> from the commandline and using the temporary file created by the script works as expected.</p>
  
  <p>I can't use the python-crontab library as this is a commercial project and that library is GPLed.</p>
  
  <p>Are there any inherent limitations in cron that prevent either approach from working?</p>