How to setup a cron job in zPanel

ZPanel LogoYes, zPanel and not cPanel.  The open source alternative to cPanel.   Setting up a cron job in zPanel is a little more difficult than setting it up in cPanel.  Hopefully the talented folks working on the newer versions can make this process a little easier.

Recently I was in the need to transfer a web program from my cPanel server to my zPanel server.  It requires a cron job in order to run correctly.  Normally, you just click the cron job link and fill in the line in cPanel.  zPanel looks like it is the same way but there are a few peculiarities I ran into.  Let me first start off with the correct steps and then I can tell you where I ran into issues.

  1. Make sure your php file is located in the domain directory.  You can’t keep it in the main directory.  For example pcprime_org\cron.php and not \cron.php or home\cron.php
  2. Be sure to change the permissions on “/var/spool/cron” to 777.  If you installed zPanel then you would know how to change the directory permissions.  If not, then ask your webhost to change it for you.
  3. You can’t add any parameters at the end of the line.  In other words nothing after the end of the directory line.

From a poster in the zPanel forums named kotakomputer:

Re: [Cron] Your script does not appear to exist at that location…

Thanks jd1pinoy, take 2 days for me to figure it out.

For those experience this Cron issue, here are the summaries:

  1. make sure /var/spool/cron owned by apache:apache and permissions 770
  2. make sure /var/spool/cron/apache owned by apache:apache and permissions 660
  3. the right Script path is: your_domain_com/CRONFILE.php or your_domain_com/SUBFOLDER/SUBFOLDER/CRONFILE.php

Example for WHMCS Script path is: your_domain_com/admin/cron.php

I didn’t follow his instructions but I think it is very similar to what I have written.  I kept getting this error message “your script does not appear to exist at this location.  I tried so many variations that I was beginning to forget which ones I had already tried.  At some point I got another error message which led me to finding this info.  I managed to not have the php file in the right location – this also required me to delete and reinstall everything in my domain directory and I didn’t have permissions set properly.  I just don’t know enough to know why all these steps were needed in the first place then again I have been quite satisfied with zpanel thus far.

I am putting this information here like I do many other posts – to make it easier to find if someone else runs into a similar situation or I run into the same situation and can’t remember the fix.
Updated: 9/17/2013
I updated zpanel to 10.1.0 over the weekend.  It must have broken my cron jobs because I have not gotten them to work since.  When I figure out the problem I will report back.
Update 2 on 9/17/2013
I think everything is back to normal.  I think the permissions on the /var/spool/cron got changed during the install process.  Once I chmod -R on the folder it LOOKS like the cron is working again.  My next job isn’t scheduled till tomorrow.
Update 3 on 9/18/2013
It didn’t work.