I'm new to all this so maybe this isn't the best solution, but I've created a shell script cache warmer.

wget --quiet http://www.example.com/custom-sitemap.xml --output-document - |
egrep -o "http://www.example.com/[^<]+" | wget --delete-after -i -

I can also do this with drush commands too using the cache warmer module.

I need to figure out how to run these commands every couple of hours.

My understanding was that I could create a custom cron job with Elysia cron that ran the script on my server, but now I am confused if this is possible / how to implement.

When I go to the script section and write the following:

*/15 * * * * custom_cron

I am told it it is an invalid line.

Can you make custom timed cron jobs then use the elysia cron API to make a module call my shell script?


  • 1
    If it is a shell script, why would you want a website to call it? Can't it be executed directly from a crontab?
    – AjitS
    Commented Feb 20, 2015 at 6:09
  • Can you explain this? How would I do that? Crontab is Cron's default jobs correct? I am 99% sure my host won't let me edit the server's cron. My host is Pantheon if that matters. Commented Feb 20, 2015 at 6:12
  • crontab is the name of a program used to create, edit and delete a list of commands run by cron on a Unix or GNU/Linux host. If you have access to this program, the system cron process will make use of this list. All hosting providers I know about (no specific experience with Pantheon) let you use this command. Commented Feb 20, 2015 at 6:36
  • help.getpantheon.com/pantheon/topics/additional_cron_jobs - 2nd comment, they don't allow it. Could this be what's preventing custom Elysia cron also? Commented Feb 20, 2015 at 6:45

2 Answers 2


I believe you can edit the crontab or by talking to hosting provider you will be able to edit the crontab file.

In case, if you have to do it in custom module using Elysia Cron API, I assume you can do it following way :

function example_cronapi($op, $job = NULL) {
  $items['example_shell_cron'] = array(
    'description' => 'Send mail with news',
    'rule' => '0 */4 * * *', // Every 4 hours
  return $items;

function example_shell_cron() {
  shell_exec ('wget --quiet http://www.example.com/custom-sitemap.xml --output-document - |
egrep -o "http://www.example.com/[^<]+" | wget --delete-after -i -');
  • Thank you! So you can create a cron job with the API, not just reference a pre-defined one! Commented Feb 20, 2015 at 14:03

The documentation under Linux for crontab is found in a manual page:

man 5 crontab

The 5 is important to indicate the section you want to see (section 1 shows you the command line documentation.)

Cron runs from / in most cases, so it won't find a script as you specified it. You have two solutions: make sure it can run from a specific user, which should be the case for root, or place the script somewhere under /var/... or /etc/... Then change the crontab script to use a full path:

*/15 * * * * /home/my_user_name/custom_cron

Using crontab you can also defined variables. Also remember that you do not have the full environment loaded. Your script needs to do that if you need a full environment.

Another way, assuming you don't need to run it every 15 minutes, is to place the script under a cron directory in /etc. In my case I use cron.hourly.

This means no setup in crontab, just copy the script under that directory, probably with a filename that makes sense such as:


That .sh file must be executable (have the x flag set) as in chmod 755 /etc/cron.hourly/drupal.sh.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.