Mailing List Archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [tlug] Efficiently executing a cron job on my webhosting server



On 07/07/07, steven smith <sjs@example.com> wrote:

Dave Gutteridge wrote:

> I'd like for it to not send me anything except error notification. Is that
> possible?

It depends on what your control panel will allow you to do.
  Probably errors get sent to stderr so to loose that you
would redirect stderr to /dev/null.  This is easy to do from
crontab, but I don't know your control panel.

Make sure your scripts only produce output on error. This sometimes requires a trivial wrapper script:

#!/bin/sh

CMD="/full/path/to/my/script arg1 arg2 ... argn"
TMP_FILE=/tmp/`basename "${CMD}"`.`date +'%Y-%m-%d_%H-%M-%S'`

${CMD} 2>&1 >"${TMP_FILE}"
retval=$?

if test ${retval} -ne 0; then cat "${TMP_FILE}"; fi

rm "${TMP_FILE}"
exit ${retval}


-- Cheers, Josh


Home | Main Index | Thread Index

Home Page Mailing List Linux and Japan TLUG Members Links