How to run linux commands in a C++ Code

Hi everyone. Im working on windows10. I want to write a c++ code for my linux service.
In my code, i want to use some linux commands.
Here is it, find /var/log -name "*.log" -type f -mtime +30

How can i do it? Im looking for system function but i failed.
Also i want to ask, how can i run my windows code on my linux service.
Im a newbei. If i ask stupid questions sorry for it.
Thank you for all.
Im looking for system function but i failed.
https://en.cppreference.com/w/cpp/utility/program/system

Also i want to ask, how can i run my windows code on my linux service.
There are some things you should do, but the simplest thing is to just run the program directly using nohup.
https://www.computerhope.com/unix/unohup.htm

As for the things you should do, there's all this spiel:
https://www.man7.org/linux/man-pages/man7/daemon.7.html

Using this implements part of that.
https://man7.org/linux/man-pages/man3/daemon.3.html

But even after you've written your daemon, you still need to plug it into the hosts service manager. Most linux distro use systemd, then there's also openrc for everything else.
https://systemd.io/
https://en.wikipedia.org/wiki/OpenRC

Don't despair, writing code to plug into the Window SCM is not fun either.
Last edited on
Thank you for all your suggestion. Finally i wrote the code that i want and run it succesfully.
Topic archived. No new replies allowed.