How to test Laravel scheduled task on FreeBSD

Sharing an issue I encountered after adding my Laravel task scheduling cronjob to freebsd and my tasks where not being executed. A quick way to test your cronjob is to use the following information:

Cronjob:

# /etc/crontab - root's crontab for FreeBSD
#
# $FreeBSD$
#
SHELL=/bin/sh
PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
# Order of crontab fields
# minute        hour    mday    month   wday    command
*               *       *       *       *       php /path/to/artisan schedule:run >> /dev/null 2>&1

Test Command:

env -i SHELL=/bin/sh PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin HOME=/home/freebsd LOGNAME=freebsd php /path/to/artsan/artisan schedule:run

The key to solving the issue is to add the path where you installed the PHP binary on the server. In my case its

/usr/local/bin
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s