cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Highlighted
Visitor
Visitor
331 Views
Registered: ‎06-25-2019

Ok Yocto Gurus - howto Petalinux redirect standard output in inittab respawn?

This is a tough one.

I would like to direct the  output of an application to a log file.

When I put myapp.elf it in Petaliniux 2016.3 inittab, the output *always* goes to the console whicy it PS1

inittab entry:

...

IS1:5:respawn:/lib/firmware/myapp.elf >/tmp/log.txt

...

How can I redirect output to a file?

I can perform it interactively of course. A goggle search shows other linux version support this.

Wha?

ps

Want to have init "respawn" if my application dies.

0 Kudos
1 Reply
Highlighted
Observer
Observer
235 Views
Registered: ‎12-21-2017

I actually ran into this exact same issue recently.  I was able to redirect my applications' output to a file using 'nohup' and redirection of the ouput stream and error stream.  I found 'nohup' was built into my rootfs by default, but you may need to enable it on your system depending on your particular configuration.

My inittab entry for my program ended up looking like this:

2:2345:respawn:/usr/bin/nohup /usr/bin/myprogram > /home/root/myprogram.out 2>&1

where '/usr/bin/myprogram' is my application binary in the rootfs, and '/home/root/myprogram.out' is the name of my log file.

Note, I played around with placing the log in various areas of the rootfs and found that some locations would not work either for permissions issues, or possibly due to when they are available to applications during the boot process.  I'm not really sure.  But placing it in the home directory worked fine.

0 Kudos