Cannot write a crontab to system

Bug #1460778 reported by Dominick Rivard
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
python-crontab
Fix Released
Low
Martin Owens

Bug Description

Hi,

I am trying to execute the following lines of code:

    comment = '# Comment'
    filename = 'filename.tab' if any(platform.win32_ver()) else False

    if filename:
        cron = CronTab(user=getpass.getuser(), tabfile=filename)
    else:
        cron = CronTab(user=getpass.getuser())

    custom_cmd = ' my_cli_name action'

    job = cron.new(command=custom_cmd, comment=comment)
    job.minute.every(ttl / 60)
    job.enable()
    cron.write()

Once it gets to the write() function it fails on read() with error:
    IOError: Read crontab drivard: crontab: must be privileged to use -u

I can from the shell create the cron without a problem.

Environment:
Mac OS Yosemite
pip show python-crontab
---
Name: python-crontab
Version: 1.9.3

How can I make it write to the user crontab?

Regards
Dominick

Revision history for this message
Dominick Rivard (dominick-rivard) wrote :

I previously said it was doing the same error on ubuntu, but I was wrong I retested it and it works on Ubuntu 14.04

Thanks

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

This error occurs because you specify a user without being root. We've seen this error before.

Don't specify the user or it will attempt to use that user instead of the filename.

Specify user=True if you want it to use the local user.

Changed in python-crontab:
assignee: nobody → Martin Owens (doctormo)
importance: Undecided → Low
status: New → Triaged
Revision history for this message
Dominick Rivard (dominick-rivard) wrote :

I can add this detail:

ls /usr/bin/crontab
-rwsr-xr-x 1 root wheel 34K 9 Sep 2014 /usr/bin/crontab

Revision history for this message
Dominick Rivard (dominick-rivard) wrote :

Fixed with user=True

Thanks

Martin Owens (doctormo)
Changed in python-crontab:
status: Triaged → Fix Committed
milestone: none → 2.0
Martin Owens (doctormo)
Changed in python-crontab:
status: Fix Committed → Fix Released
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.