How to set up a cronjob that accesses a website every 5 minutes
Question: I am hosting a site on ep.io and heroku. The way they work is that when your
website isn't accesed for some amount of time, the server is 'shut off' only
to be restarted when someone visits your domain. I noticed that this generally
will take up to 15 seconds for the page to load.

To counter this problem I want to make a cron job on another hosting I have,
that tries to access my ep.io/heroku webpage every 5 minutes for example. I
however have no clue how this would work as I have never used cronjobs.

I think I should add something like this to the crontab:

    
    
    */5 * * * * /usr/bin/curl --silent http://myapp.heroku.com
    

Is this a valid crontab line? If not, how should it be?

**Answer:**

Ok, After some searching around I found a solution, I'll post it here so
others can benefit.

Make a python script (e.g. acces_page.py) that loads a URL:

    
    
    #!/usr/bin/env python
    
    import urllib2
    
    if __name__ == '__main__':
        f = urllib2.urlopen('http://myapp.heroku.com')
        print f.read(10)
    

Then upload it somewhere on your second, not heroku, server (/webapps/myapp/
for me) and add the following line to your crontab (`crontab -e`):

    
    
    */5 * * * * ~/webapps/myapp/access_page.py > $HOME/cron.log 2>&1
    

This will run the script every five minutes, accessing your webpage defined in
your python script. To test if it works it will output the first 10 characters
of the webpage in the file cron.log in your $HOME directory.

If it says something like access denied, chmod your .py file with `chmod +x
access_page.py`.


Answer: add some thing to happen in your url page. in your example
<http://myapp.heroku.com/index.php> file.

write in DB or a file will be better

