Answer the question
In order to leave comments, you need to log in
How to create a Unit without info about the system or is it easier to finish the script?
Good day to everyone, I continue my acquaintance with bash, the question arose whether it is possible to create a Unit that will take information about the system or is it easier to change something in the script.
it is necessary that the last 10 seconds of the memory state and the CPU load are recorded in the logs =) that is, constantly =)
and one more thing, how to make the information about the networks also get into the logs like I wrote After=network.service , but it does not work =( the log file is empty =(
[Unit]
Description=make log file ^^
After=network.service
[Service]
ExecStart=/bin/bash '/restar/scripts/restar2.sh'
Type=forking
[Install]
WantedBy=multi-user.target
Alias=bash.service
#!/bin/bash
for i in $(free > /restar/logs/memory.txt | cat /proc/stat > /restar/logs/cpu.txt) {1..10}
do
sleep 1
done
for iii in $(journalctl -p err > /restar/logs/errors.txt | ip a > /restar/logs/seti.txt)
do
echo "all ok"
done
Answer the question
In order to leave comments, you need to log in
the question arose whether it is possible to create a Unit that will take information about the system or is it easier to change something in the script.
free >> /restar/logs/memory.txt &
cat /proc/stat >> /restar/logs/cpu.txt &
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question