In one of my systemd services I've implemented a thread to read in the information in /proc/stat and calculate the cpu usage for a specified interval. This thread runs every second and therefore i have the cpu load of each second.
Now I would like to add more tasks to this thread, so that it is not only running every 1 second, but also executing every 100 seconds and 1000 seconds.
I would like to store these values into seperate files, e.g.
cpu_usage_last_second.txt
// value is added each second
cpu_usage_last_100_seconds.txt
// value is added each 100 seconds
cpu_usage_last_1000_seconds.txt
// value is added each 1000 seconds
How can I achieve this with one thread, instead of creating a new thread for each task?