2

i'm trying to forward syslog to logentries.com which requires a line added to /etc/rsyslog.conf , so far so good. however, i'm running on amazon elastic beanstalk and have 3 environments (dev,staging,prod) that i'd like to route to different ports based on the environment (logentries differentiates the environment based on the port it's forwarded on)

i created an apache site running at port 8001 that just outputs the port i want to use for this specific server (since elastic beanstalk container properties get appended to the php.ini, i needed a way to output php.ini variables). then i wrote a script:

#!/bin/bash
LOGENTRIES_PORT=`curl 127.0.0.1:8001`
if [ "${LOGENTRIES_PORT}" == '' ]; then
  exit -1
fi

echo "*.* @@46.51.181.128:${LOGENTRIES_PORT}" >> /etc/rsyslog.conf
service rsyslog restart

which works great when run from the terminal but i can't seem to run on startup.

i've stuck it inside /etc/rc.d/rc.local, i've put it in /etc/rc.d/rc3.d/S99logentries (with 777 perms) with no luck. any ideas why this might be?

1
  • Can you tell how far your script actually gets when run from, say, rc.local? Do you see the new line in /etc/rsyslog.conf?
    – cjc
    Jul 4, 2012 at 15:42

1 Answer 1

1

The "old" trick to run a script as cron job or at boot time is redirect the stderr and stdout to a file to see what happens:

/path/to/your/script > /var/log/script.log 2>&1

Also keep in mind that: always use the absolute path of a command. Change the final line to /sbin/service rsyslog restart and try again.

PS: NEVER chmod 777 for a shell script!

1
  • i ended up doing this (not sure why it took me so long) and i was able to determine that apache wasn't ready by the time the script ran. after some more research i found i could get the php ini setting via the command line without apache (php -r '$foo = ini_get("ini_var_name"); var_dump($foo);') Jul 5, 2012 at 14:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .