Sending output from php script called from bash script to syslog
Im trying to create a bash script (to be called by a cron job) which calls a php file (which I have not made). Calling the php file is easy enough. The php script output a lot of stuff to stdout and I would like to redirect the output from the php script to logger so that I can monitor the progress in my remote syslog server.
I’ve tried something like:
LOGGER="logger -p cron.notice -t $ME"
php the_php_script.php &> eval $LOGGER
php the_php_script.php | eval $LOGGER
But neither work.
Another possible solution I’ve considered is to pipe the output from the php script to a log file, and then have another bash script read that file and write each line to a logger. But I would like to have one script which does everything 🙂
Can anyone please help?
Your calls to
logger are failing because
$LOGGER isn’t the command. Try this instead:
LOGGER=logger LOGGER_OPTS="-p cron.notice -t $ME" php whatever.php | $LOGGER $LOGGER_OPTS
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.