Skip to main content

Best place to add a cron job within exiting crontab...?

Comments

4 comments

  • meredevelopment
    Doing a DB backup with crontab, advice please Hi, I'm trying to add a very simple DB backup script (using mysqldump --all-databases) to a cron job. I see that there is a crontab file already used for lots of cpanel stuff, which seems to be owned by root, although I haven't worked out it's location yet. Would it be safe to add my script as a new entry to this existing crontab? If so, when I edit it with nano (sudo env EDITOR=nano crontab -e) I can make changes, but when I go to save it, it wants to save as a temp file. I'm very open to suggestions here. I'm relatively new to *unix and whm/cpanel and I just want to run a .sh once a day, any way is fine. Thanks! Ben
    0
  • JaredR.
    Please do not post the same question to more than one forum section. I have merged your two threads into a single one. [QUOTE]when I edit it with nano (sudo env EDITOR=nano crontab -e) I can make changes, but when I go to save it, it wants to save as a temp file.
    That is the expected behavior. When you run the crontab command with the -e switch, it opens the actual cron file for the user (located in /var/spool/cron) with a temporary filename for editing, normally in /tmp. When you save the changes and exit the editor, crontab automatically copies the temporary file from /tmp to the correct location in /var/spool/cron. This is explained briefly on the crontab man (manual) page: -e This option is used to edit the current crontab using the editor specified by the VISUAL or EDITOR environment variables. After you exit from the editor, the modified crontab will be installed automatically.
    You can read the crontab man page by typing man cron at any shell command prompt.
    0
  • meredevelopment
    Ok thanks Jared, the double post was a mistake (I'd not seen that it was a moderated forum and thought the post had failed). Thanks for the crontab info. So I should be ok to add my own script entries to the existing crontab file I assume? Any idea if they will be removed if cPanel/WHM is updated? Ben
    0
  • JaredR.
    A cPanel update will not remove a cron job you add to root's jobs using the crontab command.
    0

Please sign in to leave a comment.