Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:

ME=basename $0

LOGGER="logger -p cron.notice -t $ME"

php the_php_script.php &> eval $LOGGER

Also tried:
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?

share|improve this question
I'd look if there isn't a syslog client implementation in php first and use logger if there's none : That will allow you to control logging line per line inside the_php_script.php; edit : – user130370 Jan 5 '13 at 20:56
up vote 1 down vote accepted

Your calls to logger are failing because $LOGGER isn't the command. Try this instead:

LOGGER_OPTS="-p cron.notice -t $ME"

php whatever.php | $LOGGER $LOGGER_OPTS
share|improve this answer
Wow, that was a fast reply And it even works! Thanks a lot :) – Lonos Jan 5 '13 at 21:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.