Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
Managing Cronjobs with Laravel
Oct 27, 2015 @ 11:18:06

The SitePoint PHP blog has a tutorial posted showing you how to use the Laravel "scheduler" to handle cron jobs and the execution of custom commands.

There are times when your application needs to run administrative tasks periodically on the server. Whether you want to send out emails to your users or clean up the database tables at the end of the day, you will need a task scheduling mechanism to take care of the tasks, when it’s time. Cron is a task scheduler in unix-like systems, which runs shell commands at certain intervals.

They start with some of the basics of cron and how is configuration is defined. Since the Laravel scheduler makes use of the same format, they want to be sure everyone is on the same page. Next they show you how to create a custom command in Laravel, a simple script designed to be run on the command line. The tutorial shows how to execute the simple command and how to add it to your application's "commands" list in the configuration. Finally they get to scheduling the commands, defining a schedule method and using the Laravel helper methods to set the execution time to something like "daily", "hourly" or, if you need something a bit more custom, a full cron-formatted string. The post ends with the addition of the Laravel scheduler execution to the system cron, set to run every minute.

tagged: manage cronjob laravel scheduler custom tutorial command

Link: http://www.sitepoint.com/managing-cronjobs-with-laravel/

Managing Cron Jobs with PHP
Apr 08, 2011 @ 12:39:30

New on NetTuts.com there's a tutorial about using cron with PHP and how to manage the jobs your server currently runs.

The cronTab, or “Cron Table”, is a Linux system process / daemon which facilitates the scheduling of repetitive tasks thereby easing up our day to day routine. In this tutorial, we’ll create a dynamic PHP class that, using a secure connection, provides us with a means to manipulate the cronTab!

They explain the cron format (time and script to run) and how to set up a crontab management class that uses the ssh extension for PHP to communicate with the remote server. Their class includes methods for setting up jobs, writing them out to the cron file, removing existing jobs and dropping the entire cron file at once.

tagged: cronjob manage ssh tutorial