ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Conditional emptying of log files for node without deleting the file

asked 2023-03-15 06:57:29 -0500

shouvik1984 gravatar image

Dear Experts,

As per my system architecture there is a need to take archives of logs under ~/.ros/log/latest/ folder. However in our operation we are not allowed to stop and restart rosmaster and all the nodes. Hence the symlink of the latest folder will be perennial as well as the log files will be appended each time the node is exercised. What we need is to clear the content of the *.log files on an event (which could be read from a suitable rostopic). The event marks a culmination of a particular cycle of oepration and hence the logs between the event is relevant for relating it to a cycle.

The command

rosclean purge -y

Is not helpful as it clears off the folder and the handle to the files are lost. After that unless and until the all the nodes and rosmaster is restarted the logging will not commence.

Is there a way we can issue emptying of the *.log files on an event with the constraint that the rosmaster and nodes cannot be shutdown/killed.

The following crude solultion does not yield proper result

for logs in ~/.ros/log/latest/*.log; do
echo "" > $logs
done

Any help will be appreciated

Regards Shouvik

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2023-03-17 06:57:04 -0500

Mike Scheutzow gravatar image

We handle this problem using the --screen option to roslaunch. This redirects all log messages to stdout/stderr, giving our code control of log message storage and rotation.

It's a good idea to set environment variable PYTHON_UNBUFFERED=1 for roslaunch in order to suppress the internal stdout/stderr buffering done by python.

edit flag offensive delete link more

Comments

Actually as the system is remote and unattended, logs are needed for prognostics for analyzing if there are some unexpected behavior, hence we cannot affort to use output:=screen. As the remote it is going to run the rosmaster and the nodes continuously. Is there a way we can keep changing the log file name during each new event?

shouvik1984 gravatar image shouvik1984  ( 2023-03-17 07:30:21 -0500 )edit
0

answered 2023-03-15 08:16:09 -0500

gvdhoorn gravatar image

Is there a way we can issue emptying of the *.log files on an event with the constraint that the rosmaster and nodes cannot be shutdown/killed.

In the context of ROS 1, this is not supported by any of the provided, standard functionality.

That's not to say it might not be possible to implement a work-around, but at least in the standard tooling, what you describe is not supported.

edit flag offensive delete link more

Comments

Unattended remote systems have the rosmaster running indefinitely (unless there is a maintainance needed). During that time we cannot issue rosclean. We are looking for ways and means to keep periodically cleaning the roslogs so that it does not occupy immense amount of space.

Please suggest.

shouvik1984 gravatar image shouvik1984  ( 2023-03-17 06:26:51 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2023-03-15 06:57:29 -0500

Seen: 308 times

Last updated: Mar 17 '23