OK, this is what I would do. Check whether logger (typically
/usr/bin/loggger) is installed on the system. If it is, create a script
that runs at boot as follows:

#!/bin/ash [if /bin/bash is available, I'd use that]

/usr/bin/logger -t xyzzy "SHELL=$SHELL"
/usr/bin/logger -t xyzzy "me=$(whoami)"
echo "test" > /tmp/me.log
/usr/bin/logger -t xyzzy "Status after file write: $?"

What that does:

 - /usr/bin/logger makes entries in syslog, so no need to worry about
   writing files

 - "-t xyzzy" will tag each syslog entry with "xyzzy". Of course you can
   use any string, but that allows you to 'grep xyzzy /var/log/messages'
   (or wherever syslog writes)

 - we check the shell (is it really ash?)

 - we check who we are (are we really root?)

 - we try writing to a file and report the status of doing so

Just looking at your original post, the other thing I'd change is the
relative file reference. Rather than writing to ../stdout.log, just write
to /tmp/stdout.log. Better still:

python3 ./main.py --id "NAS" 2>&1 | tee /usr/bin/logger -t xyzzy

...and have it sent to syslog.

hth
-- 
Linux Tips:     https://www.tiger-computing.co.uk/category/techtips/

-- 
  Next meeting: Online, Jitsi, Tuesday, 2021-03-02 20:00
  Check to whom you are replying
  Meetings, mailing list, IRC, ...  http://dorset.lug.org.uk
  New thread, don't hijack:  mailto:dorset@mailman.lug.org.uk

Reply via email to