Code For System Shutdown C Program in Linux Ubuntu
Learn How To Code A System Shutdown C Program in Linux Ubuntu Operating System. This C Program To ShutDown Your Linux System makes use of Linux System Calls. This is an Auto Shutdown C Program which will Turn Off your System within the mentioned Time period in the parameters.
The system() method is defined in the Standard Library in C Programming. Hence, it is important to include stdlib.h header file.
The system() method takes in the following arguments:
- Shutdown / Restart
- Process / Cancel
- Time Limit
You have the option to cancel the shutdown timer if you have activated it by executing the program given below. All you need is to type the following command.
C Program To Shutdown A Linux Ubuntu Operating System
system("shutdown -P 10");
If you have any compilation errors or doubts in the above C Program To Shutdown Your Linux Ubuntu System using PThread, let us know about in the Comment Section below.
Will the same C Program to shutdown system work in Linux versions such as Mint, Fedora, Redhat?
Yes. I tried it on Fedora PC. It works perfectly fine. I believe this code is executable in all the Linux distributions such as Fedora, Mint, OpenSUSE, Debian, Slackware, Arch and obviously Ubuntu, and many more.