Why are ros logs stored under '/root/.ros/log' ?

asked 2017-09-14 05:40:13 -0500

Jasmin gravatar image

updated 2018-06-22 10:46:59 -0500

Hi everyone!

I'm working with ros-indigo under ubuntu 14.04. Normally ros logs are stored under ~/.ros/log !? and can be deleted when running rosclean purge.

In my case, log files are saved under ~/.ros/log and also under ./root/.ros/log and I don't know why they are stored there! Are some nodes run with root privileges or something because I'm running so many ros nodes in background? Well the root itself don't know the command rosclean...

I need to Know why is that happening? and How can I tell ROS to delete logs regularly or to not create log files at all? This last question was already asked here but It was a while ago.

For instance I'm going with ROS_LOG_DIR=/tmp for the user but unable to do the same for the root.

When ROS is using ./root/.ros/log it feels like the ~ is pointing on root. Is there any problem in launching ROS nodes from a python script? In this case it feels like the root is the owner of the launched ROS nodes...

Your help would be appreciated.

edit retag flag offensive close merge delete


I'm not sure if it is possible to force the ~ to point on a specific user (not root) when running ROS nodes in different conditions. but for instance, when running the codes that run the scripts launching the ROS nodes I forced the user to be my normal user with sudo -u user and it worked.

Jasmin gravatar image Jasmin  ( 2018-06-22 05:57:36 -0500 )edit

sudo runs things as root (by default). That is why logs were written to /root/.ros/log. ~ is evaluated by the shell, and as that was run as root, it resolved to /root.

In general running ROS nodes as root is discouraged and most of the times not necessary.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-22 15:13:47 -0500 )edit

You're right, but I was not running the nodes as root in purpose, I was running the nodes via a startup script. but since I added the script to "/etc/init.d/" it was run by root causing the launched ros nodes to be owned by the root as well. I should correct the way I'm running startup nodes!

Jasmin gravatar image Jasmin  ( 2018-06-24 04:17:39 -0500 )edit

I was running the nodes via a startup script

That would have been good to include in your question text, as that is the most likely cause of why the logs end up in /root/.ros/log.

gvdhoorn gravatar image gvdhoorn  ( 2018-06-24 05:08:08 -0500 )edit