setting cron job - crontab vs ispconfig panel

I use a CMS like application that use cron to send email notification every 30min, if the log contains something new.
A bit naïevely, I followed the instalation tutorial of my app, ran "crontab -e", added a line like this "*/30 * * * * php /var/mydomain.com/web/check.php"

At first I was happy as I could see that the cron job was indeed set-up, but not anymore for few reason :
- if I run "crontab -e" again, I c'ant see/edit the cron job I created, it's like the line has diseappeared (for instance I would like it to run every 5minutes)
--> I would assume that ISPConfig had re-edited this file to its liking and deleted my cron job, however
- if I go to the log of my app, I still can see that my cron job is done every 30min
I did some research and looked for my cron job in /etc/cron.d/ but couldn't find it.
--> I thus wonder where could that job be specified now.

Second, I then say to myself, stupid, why don't you use ISPConfig cron panel to create your cron job
I thus created a cron job in ISPConfig, however if I specify an the url of check.php, the job will run "wget /var/mydomain.com/web/check.php" , and I obviously don't want that.
Thus, in the same folder, I created a check.sh file containing "php /var/mydomain.com/web/check.php".
If I run "sh /var/www/check.php" check.php is indeed run.
I finally created a cronjob in ISPConfig with "/var/mydomain.com/web/check.sh" hopping it would be ran my script. But it's not.
I did some research and tried "chmod -u+x /var/mydomain.com/web/check.sh" but it didn't help
I double checked in "/etc/cron.d/ispc_chrooted_web1", where I can indeed see the cron job I created in ISPConfig.

So my issue is double, what happened with my first cron job, has it been "managed" in a way by ISPConfig
What have I done wrong in setting up a cron job in ISPConfig

1. Are you checking using crontab -l with the same user you created the crontab?
2. The crontab files are stored in /var/spool/cron/crontabs/
3. You should never put check.sh in your web folder!!!
4. To check what ISPConfig generates as cron file look in /etc/cron.d/ispc_webxx, pay attention that this cron is run as the web user of the domain and not root

4. To check what ISPConfig generates as cron file look in /etc/cron.d/ispc_webxx, pay attention that this cron is run as the web user of the domain and not root

Click to expand...

yes I've been there, and indeed see the cron job I created, but it do not seems to work.
The owner/user of check.sh is the web user, as one could wish. In command line this user can run the script "sh /var/mydomain.com/web/check.sh" , but the job set in ISPConfig is not run...
Do you get an idea what I may have done wrong ?
Again the cron job created in ISPConfig contains the path to check.sh and check.sh contains "php /var/mydomain.com/web/check.php"

To my understanding, after some research, cron log is not activated by default. I thus edited /etc/rsyslog.conf and uncommented the line with cron.* /var/log/cron.log, then restarted cron and rsyslog service

A fresh start being useful, I deleted the cron job I created manually, as well as the one in ISPConfig

Then I created the cron job manually again, and it work's like a charm, it is recorded in both the cron.log file (much easier to read than rsyslog.log) and in my simili-cms log.
I can now go further and delete this cron job (actually comment it)

Then, logged-in as web5, I created a script, nano /var/www/mydomain.com/private/check.sh, containing /usr/bin/php /var/www/mydomain.com/web/check.php , finally made executable with chmod 755 /var/www/mydomain.com/private/check.sh
If I run cd /var/www/mydomain.com/private/ then ./check.sh, check.sh is run, as well as check.php, as it is recorded in the log of my simili-cms

Finally, I create a cron job in ISPConfig asked to run /var/www/mydomain.com/private/check.sh every 5 minutes.
After a little while, the cron job appears to be run as it is recorded in /var/log/cron.log
Sep 27 10:45:01 vpsXXXXXX CRON[1559]: (web5) CMD (/var/www/mydomain.com/private/check.sh >/dev/null 2>&1 #mydomain.com)
However, if the cron job is run, check.sh do not seems to be run, and check.php is not, as I have no records in the log of my simili-cms.

For debug purpose I would open the /etc/cron.d/ispc_webxx file and change MAILTO='' to MAILTO='[email protected]'.
Then inside check.sh I would add some debug output like:
echo 'debug'
which php
ls -la /usr/bin/php
/usr/bin/php -v
ls -la /var/www/mydomain.com/private/check.sh
ls -la /var/www/mydomain.com/web/check.php
and see if I get a mail with that contents to help me debug the issue.

P.S.: Why can't you access check.php through wget? I am only using this type of cronjob for my clients and they work fine.

For debug purpose I would open the /etc/cron.d/ispc_webxx file and change MAILTO='' to MAILTO='[email protected]'.
Then inside check.sh I would add some debug output like:
echo 'debug'
which php
ls -la /usr/bin/php
/usr/bin/php -v
ls -la /var/www/mydomain.com/private/check.sh
ls -la /var/www/mydomain.com/web/check.php
and see if I get a mail with that contents to help me debug the issue.

P.S.: Why can't you access check.php through wget? I am only using this type of cronjob for my clients and they work fine.

Click to expand...

I may be even more dumb than one could guess.
I assumes that if I were accessing check.php through wget, it would actually not run the script, but download it hat I usually use wget for in command line !!!

Otherwise, I insist on doing it through ISPConfig, not only to have a "cleaner" set-up, which is not very true, but because it force me to dig into unknown area, and learn, in this case about cron, while I could have simply set-up the cron job as suggested in the documentation of the simili-cms without knowing much of what I'm doing, despite it works ;-)

Yes, but you do not need to call a shell script which calls php, just enter an URL into ISPConfig Command to run: http://mydomain.tld/check.php and your script will get called using the php version defined for that website...

Yes, but you do not need to call a shell script which calls php, just enter an URL into ISPConfig Command to run: http://mydomain.tld/check.php and your script will get called using the php version defined for that website...

Click to expand...

yes I'm a dumb as** , it indeed works, I miss-interpreted what would wget do in the context of a cron job...

Anyway, no I've been to far to quit, an I would like to have a cron job working with check.sh, just for the sake of learning, and acquire this ability

I edited /etc/cron.d/ispc_webxx file and change MAILTO='' to MAILTO='[email protected]om'.