0
I use postfix
linked to an commercial smtp server for cron
jobs to send their owners an email in case of error/warning.
This is a one box Arch setup.
postfix
works. So does cronie
. But although the simplest of all cron jobs does fire, I get an email from the cron daemon at every execution, which reads:
/bin/sh: warning: command substitution: ignored null byte in input.
The cron rule, to be run every minute as a test, is:
MAILTO=MYUSERNAME@LOCALHOSTNAME
* * * * * eval "export $(grep -Ez DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep -u $LOGNAME gnome-session)/environ)";/home/USERNAME/test
and the executable ~/test is basically:
#!/bin/bash
/usr/bin/notify-send 'Hello world!' --icon=dialog-information
I understand that grep -Ez [...]
introduces a null byte, as is made necessary by its output with some unusual characters.
My toy example would function properly, if it weren't for that specific warning being emailed to USERNAME at every execution. How do I get rid of that ?
1As your system uses the "user bus" style in /run, rather than a random session bus address in /tmp, this whole greppage is now optional and you can safely hardcode the bus address. (Or even rely on recent libdbus already having it coded as a default when the environment variable is missing.) – user1686 – 2018-10-12T19:50:41.357
@grawity: I absolutely did not know that. Would you like to write a simple answer to that effect, so others may actually not miss your comment. Just bear in mind that I was looking for portability, across Linux systems, something my answer does not quite acheive.... Tx. – Cbhihe – 2018-10-12T19:56:39.437