Python script works but does not actually update cron. crontab -u -l shows no changes even though code ran without error

Bug #1538650 reported by Adam Rothschild
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-crontab
Invalid
Undecided
Unassigned

Bug Description

Python script works but does not actually update cron. crontab -u -l shows no changes even though code ran without error

from crontab import CronTab
import sys

# Create a new non-installed crontab
cron = CronTab(user='aroth')
job = cron.new(command='/usr/bin/echo')

job.minute.during(5,50).every(5)
job.hour.every(4)

job.dow.on('SUN')
job.month.during('APR', 'JUN')
job.month.also.during('OCT', 'DEC')

job.every(2).days()
job.setall(1, 12, None, None, None)
job.enable()
job2 = cron.new(command='/foo/bar', comment='SomeID')
job2.every_reboot()

jobs = list(cron.find_command('bar'))
job3 = jobs[0]
job3.clear()
job3.minute.every(1)

sys.stdout.write(str(cron.render()))

This works as expected but when I perform crontab -l -u aroth it is blank.

Same thing when I remove a job I don't see it in the render but it is still there when I type crontab -u aroth -l

Is it writing to a different file?
Thanks

Revision history for this message
Martin Owens (doctormo) wrote :

Try cron.write() before you exit.

Revision history for this message
Adam Rothschild (adam-rothschild) wrote : RE: [Bug 1538650] Re: Python script works but does not actually update cron. crontab -u -l shows no changes even though code ran without error

Many thanks

Adam Rothschild
Analyst | 1010data
p: 1.646.532.5057
e: adam.rothschild@1010data.com

-----Original Message-----
From: <email address hidden> [mailto:<email address hidden>] On Behalf Of Martin Owens
Sent: Wednesday, January 27, 2016 12:03 PM
To: Adam Rothschild
Subject: [Bug 1538650] Re: Python script works but does not actually update cron. crontab -u -l shows no changes even though code ran without error

Try cron.write() before you exit.

--
You received this bug notification because you are subscribed to the bug report.
https://bugs.launchpad.net/bugs/1538650

Title:
  Python script works but does not actually update cron. crontab -u -l
  shows no changes even though code ran without error

Status in python-crontab:
  New

Bug description:
  Python script works but does not actually update cron. crontab -u -l
  shows no changes even though code ran without error

  from crontab import CronTab
  import sys

  # Create a new non-installed crontab
  cron = CronTab(user='aroth')
  job = cron.new(command='/usr/bin/echo')

  job.minute.during(5,50).every(5)
  job.hour.every(4)

  job.dow.on('SUN')
  job.month.during('APR', 'JUN')
  job.month.also.during('OCT', 'DEC')

  job.every(2).days()
  job.setall(1, 12, None, None, None)
  job.enable()
  job2 = cron.new(command='/foo/bar', comment='SomeID')
  job2.every_reboot()

  jobs = list(cron.find_command('bar'))
  job3 = jobs[0]
  job3.clear()
  job3.minute.every(1)

  sys.stdout.write(str(cron.render()))

  This works as expected but when I perform crontab -l -u aroth it is
  blank.

  Same thing when I remove a job I don't see it in the render but it is
  still there when I type crontab -u aroth -l

  Is it writing to a different file?
  Thanks

To manage notifications about this bug go to:
https://bugs.launchpad.net/python-crontab/+bug/1538650/+subscriptions

The content of this e-mail message and any attached files transmitted with it are to be treated as confidential information and are intended solely for the use of the individual or entity to whom they are addressed. If the reader of this e-mail is not the intended recipient or his or her authorized agent, the reader is hereby notified that any reproduction, distribution, or disclosure of this e-mail is prohibited. If you have received this e-mail in error, please notify the sender by replying to this message and delete this e-mail immediately.***1010data, Inc. and its affiliates ("1010data") are not responsible for any advice concerning the use of its software or services or the data manipulated by its software, except to the extent 1010data has specifically undertaken such responsibility in a validly binding contract. 1010data shall have no responsibility for any decision concerning the appropriate method of use or application of its software or services or the data therein in connection with any transaction. Any decision concerning how, where and when to use this facility remains the sole responsibility of the user.

Martin Owens (doctormo)
Changed in python-crontab:
status: New → Invalid
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.