Month: December 2016

Custom cron interval on openshift cron cartridge

Openshift v1 does not allow custom cron times, cronjobs can only be placed in the folders minutely, hourly, daily, weekly and monthly.

You can use the script below to run a cronjob every 5 minutes. You can vary the timestamp by modifying the +4 parameter. The script must be placed in the minutely folder. Here it will run every minute, and write a timestamp to a temporary file. It will check the creation date of the file, and if it is more than 4 minutes ago the cronjob will run. After that the file will be removed and recreated via the touch command.

The example below will run a PHP cronjob.

#!/bin/bash
if [ ! -f $OPENSHIFT_DATA_DIR/last_run ];
then
    touch $OPENSHIFT_DATA_DIR/last_run
    cd $OPENSHIFT_REPO_DIR;php cronjob.php RememberCron
else
 if [[ $(find $OPENSHIFT_DATA_DIR/last_run -mmin +4) ]]; then #run every 5 mins
   cd $OPENSHIFT_REPO_DIR;php cronjob.php RememberCron
   rm -f $OPENSHIFT_DATA_DIR/last_run
   touch $OPENSHIFT_DATA_DIR/last_run
  fi  
fi

Leave a Comment

Mopidy http server on network

I recently installed the mopidy audio player on my raspberry pi to stream music in my livingroom. After installing it it was not immediately clear to me how I could access the installed web client. The example configuration did show an example mpd section with a network config. But that did not make the web interface available at port 6680. It turns out that the http interface has a different config. This is explained in the docs but I did not get that far after the getting started guide. The example below makes mpd listen on all interfaces.

[http]
hostname = ::

Please note that this will make the HTTP server available to every node on the network. This HTTP endpoint will be available without any security protections.

Leave a Comment