Patrick
Patrick

Reputation: 3172

What is the benefit of wrapping a PHP cron job inside a Bourne Shell Script (.sh)?

I've come across a checklist for creating a new PHP cron at my job and one of the directions is:

Add a wrapper file that calls the main part of your job code as cron_[name].sh

A sample cron.sh:

#!/bin/sh
###########################################################
# This job sends out the daily digest emails
###########################################################
. $DS_JOBS_DIR/cron_common.sh

cd $DS_JOBS_DIR/digests
$DS_PHP daily_digest.php

What is the benefit of wrapping a PHP cron inside a shell script?

Upvotes: 1

Views: 309

Answers (2)

Alex Howansky
Alex Howansky

Reputation: 53636

The only reason I can think of for doing this would be to allow the PHP script to gain access to shell environment variables (i.e., that might contain configuration settings) which get set in cron_common.sh.

Upvotes: 2

Brian
Brian

Reputation: 8626

No reason.

But you could perform multiple things in the shell script after that - more php or other tasks.

But my main guess is that if you found it in the 'checklist for creating a new PHP cron', then it's is simply how the organisation want things done - due to factors above, or simply how their IT Manager/server administrators are preferring it be done.

Upvotes: 2

Related Questions