continously running c++ code

i have three separate blocks of c++ code, one for writing to a text file and the other for reading from that file and sending to the serial port and the other for blinking an led attached to the output header. Right now i am able to run them separately using the ./a.out command. In linux, how can i make these separate blocks of code run continuously even after connecting power to my cpu without typing the ./a.out command?
Linux task scheduler: cron. The file in which tasks to schedule are defined is crontab.

You can either run all three blocks as a normal program (if they're in the same source file) at scheduled intervals, or put the three blocks in separate files (to create three distinct executables), and place all three in the crontab.

However, crontab's smallest interval is one minute, so you might want to write a quick shell script that includes the three blocks, and place the script in the crontab.
A simple pseudocode example:
while true
    run codeblock1
    run codeblock2
    run codeblock3

This will constantly execute the three programs. Keeping them running is a different story.
Also, if you use this method (writing a script and placing it to run every minute or something) you probably want to add lines to kill any already-running instances of the three programs, so you don't end up with infinite programs (adding an instance of the script each minute will eventually cause problems).
Topic archived. No new replies allowed.