Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I recently changed my username, and I can't seem to access my crontab now:

% crontab -e
crontab: no crontab for blackl - using an empty one

I thought I'd just edit the one I had under my old username, copypaste the jobs to the new one, and then use crontab -r to remove the old one.

% sudo crontab -eu olduser
crontab: user `olduser' unknown

Oops.

I dug around a bit and found where the crontabs are stored (/usr/lib/cron/tabs) and copied my old one out of there. The first line, though, is this:

# DO NOT EDIT THIS FILE - edit the master and reinstall.

It seems to me that for whatever reason, manually removing the old crontab with something like sudo rm /usr/lib/cron/tabs/olduser would be a bad idea. What is the correct way to do this?

share|improve this question

1 Answer 1

[root@localhost cron]# pwd
/var/spool/cron
[root@localhost cron]# ll
total 4
-rw------- 1 root     root   0 Jul 13 12:06 root
-rw------- 1 max      max    20 Oct 22 12:22 max

Here particular users crontabs are stored.

This is the content of man usermod

-l, --login NEW_LOGIN
           The name of the user will be changed from LOGIN to NEW_LOGIN. Nothing else is changed. In particular, the user´s home directory name should probably be changed manually to
           reflect the new login name.

Here clearly mentioned that Nothing else is changed so the file under /var/spool/cron will not be updated, because this file will be created while creating user account (path may vary in your system)

just rename this file to your new username.

After that type crontab -l it will list your old crontab also.

you are telling that this is not the correct method right?

If i get any other method i will update my post.

share|improve this answer
    
Is it as simple as renaming the crontab file? I'm wary of doing anything like that manually because of the warning on the first line of the file. I'm not saying your other answer was incorrect, just that it didn't answer my question. :P –  Blacklight Shining Oct 22 '12 at 7:52
    
As an aside, I didn't use usermod (as a matter of fact, OS X doesn't seem to /have/ a usermod). I just logged in using a temporary account, opened Users & Groups Preferences, right-clicked on my account, chose Advanced Options…, and updated the Account name and Home directory fields. I then used mv to rename my home directory and rebooted. This seems to have worked for the most part; that was a few weeks ago and this is the only trouble I've had with it so far. –  Blacklight Shining Oct 22 '12 at 8:02
    
@BlacklightShining I don't no about os x. so sorry... –  max Oct 22 '12 at 8:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.