Rock The Click

Media, Advertising, Tech and Mumbo Jumbo

Setting up market hours crontab

Posted in Tech How To
at 2015.09.11
With 0 Comments

How to setup a crontab on unix or linux update stock price information and only run during market hours.

Ssh into your server using putty or terminal: Open up your cron settings by typing crontab –e

*/15 9-17 * * 1,2,3,4,5 php /home/ftp-username/public_html/app/stock.php

Save it by pressing [Esc], :q!, [Enter]

If you’re on an Amazon ec2 instance or a locked down webhost host you might need to include sudo prior to that command in order to have permissions to save properly.

The script above would run every 15 minutes, Monday -> Friday from 9AM to 5PM. Since stock quotes are generally delayed 15-20 minutes I want to let it run all the way into 5PM EST even though the US markets close at 4:30 EST because I wanted to be sure it’s showing the most up-to-date price after the close and throughout the night.

Leave a Reply