Jump to content

How to create cron job without admin panel


Recommended Posts

I'm trying create simple new cron job for my module. Everywhere I see to do it I must define my cron in admin panel. But it seems stupid, because I won't write to each person which download my module to activate this cron manually. I wrote cron jobs for Wordpress and Magento without problem, but in Prestashop I can't find any tutorial when would be described this process. It is possible to write and activate cron automatically?

Link to comment
Share on other sites

The way i do it is by manually assign a cron job via ssh

 

in ssh i would do the following

 

$EDITOR=nano crontab -e

 

It will open a file with all your existing cronjob (if any), and you can start writing your cronjob to call the endpoint of your module

 

example: your module is in this URL http://example.com/path/to/your/modules

 

then your cron entry would be something like this

 

* * * * * * curl 'http://example.com/path/to/your/modules'

 

The idea here is to create a 'hidden' landing page for your module. This so called landing page (i would refer it to as endpoint) would then be a simple script to call your routine.

 

Another scenario is to create a hook, which visually does not print anything. But the hook actually run the script you want to execute. Then, you can place your hook to almost every page so that each time that page is loaded by users, the script gets called.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...