OpenShift cron does not run

Gaia asked:

I have the following file

[subdomain.rhcloud.com minutely]> pwd
/var/lib/openshift/username/app-root/repo/.openshift/cron/minutely
[subdomain.rhcloud.com 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 ticktock.sh
[subdomain.rhcloud.com minutely]> cat ticktock.sh
*/1 * * * * username php ../../../cron/status.cron.php

[subdomain.rhcloud.com minutely]> php ../../../cron/status.cron.php
[subdomain.rhcloud.com 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 ticktock.sh.

So I tried to invoke it manually:

[subdomain.rhcloud.com minutely]> ./ticktock.sh
./ticktock.sh: 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,

[subdomain.rhcloud.com 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 ticktock.sh became

[subdomain.rhcloud.com minutely]> cat ticktock.sh
*/1 * * * * 546e69f54382ec6013000027 /opt/rh/php54/root/usr/bin/php ../../../cron/status.cron.php

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

[subdomain.rhcloud.com minutely]> ./ticktock.sh
./ticktock.sh: 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.

#!/bin/bash
/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.