OpenShift cron does not run

Gaia asked:

I have the following file

[ minutely]\> pwd
[ minutely]\> ls -lha
total 4.0K
drwx------. 2 username username 24 Nov 20 21:08 .
drwx------. 3 username username 21 Nov 20 20:46 ..
-rwxr-xr-x. 1 username username 73 Nov 20 20:54
[ minutely]\> cat
*/1 * * * * username php ../../../cron/status.cron.php

[ minutely]\> php ../../../cron/status.cron.php
[ minutely]\> 

as shown, the contents of the file execute fine. the file permissions seem right. but the Cron 1.4 cartridge doesn’t seem to fire

So I tried to invoke it manually:

[ minutely]\> ./
./ line 1: */1: No such file or directory

It tells me the file that exists there doesn’t exist.

So I tried the full path to php,

[ minutely]\> /opt/rh/php54/root/usr/bin/php -v
PHP 5.4.16 (cli) (built: Oct 23 2014 05:04:35) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

and became

[ minutely]\> cat
*/1 * * * * 546e69f54382ec6013000027 /opt/rh/php54/root/usr/bin/php ../../../cron/status.cron.php

but it still doesn’t execute, via cron or command line

[ minutely]\> ./
./ line 1: */1: No such file or directory

What am I missing here?!

My answer:

The OpenShift cron directories are meant to contain the actual scripts to be run, not traditional crontab-style entries.

So you should instead write a simple script to call your PHP code.

/opt/rh/php54/root/usr/bin/php ../../../cron/status.cron.php

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.