How to schedule a cron on pythonanywhere server

If you have hosted your Django app on pythonanywhere.com server and you want to schedule a cron job on the server to execute some task periodically ( daily or hourly) then this article is for you.

Cron jobs are executed after a fixed interval of time, repetitively until stopped explicitly. This may come handy if you want to send bulk mails every hour or you may want to take a backup of your database or basically anything you want to perform periodically.



Creating and hosting Django app:

In one of our previous article we discussed how to create a django application in less than 5 minute. This article contain step by step process to develop django app complemented by code on github.

In another related article we discussed how to host a django app on pythonanywhere.com server for free. In this article we listed benefits of pythonanywhere server and steps to host the app in details.  

Article consist of screenshots to help you and a video tutorial showing working of article steps.



How to schedule cron on pythonanywhere server:

      Please comment if you have any query.  Create a free account on pythonanywhere with 30 days money back guarantee on paid account. Pay monthly.

      First make sure you have created your custom management command which will perform the task. e.g. sending emails or creating backup etc.

      First run this command from terminal and check if it is working as expected or not.

      Go to schedule tab in your account on pythonanywhere server.

      how to schedule a cron on pythonanywhere server

      As you can see that you can schedule a cron on daily basis. Hourly basis scheduling is available to paid users only.

      Time is given in UTC format.

      Select the hours and minutes accordingly and in command path input field enter the complete command with below format.
      absolute-path-to-python    absolute-path-to-manage.py-file  command_name e.g.

      /home/100rupeekart/VirtualEnv/bin/python3.4   /home/code108/myproject/manage.py  send_mail_command


      Add the command. To see the output of the command later on, click on the command in list of scheduled commands.


      Related Articles:
      Python Script 3: Validate, format and Beautify JSON string Using Python
      Validating json using python code, format and beautify json file using python, validate json file using python, how to validate, format and beautify json...
      Encryption-Decryption in Python Django
      How to encrypt and decrypt the content in DJango. Encrypting the critical information in Django App. Encrypting username, email and password in Django...
      Adding Robots.txt file to Django Application
      Adding robots.txt file in your Django application. Easiest way to add robots.txt file. Django application robots.txt file. Why should you add robots.txt file in your Django Application....
      Solving Django error 'NoReverseMatch at' URL with arguments '()' and keyword arguments '{}' not found.
      Solving Django error 'NoReverseMatch at' URL with arguments '()' and keyword arguments '{}' not found, URL not found in Django, No reverse match in Django template error...

      0 thoughts on 'How To Schedule A Cron On Pythonanywhere Server'
      Leave a comment:


      *All Fields are mandatory. **Email Id will not be published publicly.


      SUBSCRIBE
      Please subscribe to get the latest articles in your mailbox.



      Recent Posts:






      © pythoncircle.com 2018-2019