How do I configure Ubuntu to run a python (backup) script every night at midnight?

Posted on

Problem :

New to Ubuntu (and Linux in general) and have whipped up a quick python script to backup my files and do some other housekeeping. I don’t see any service scheduling tools and was wondering what the best way to do this is.

Solution :

Use cron.

  1. Run crontab -e

  2. Add this line:

    0 0 * * * ~/myscript.py
    

    Or simpler:

    @daily ~/myscript.py
    
  3. Exit the editor.

See the Wikipedia article for an explanation of crontab format.


I don’t know which editor Ubuntu picks by default, but it’s likely to be a terminal-based one. If it’s nano, use CtrlX to exit. For vim, Esc, then :wq Enter.

To get the GNOME Editor, use export EDITOR=gedit before running crontab.

install webmin first. it gives you an easy way to setup scheduled (cron) jobs. just point and click in a GUI.

Leave a Reply

Your email address will not be published.