Run as a daemon or service: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 7: | Line 7: | ||
Note that in some language implementations it may not be possible to disconnect from the terminal, and instead the process needs to be started with stdout (and stdin) redirected to files before program start. If that is the case then a helper program to set up this redirection should be written in the language itself. A shell wrapper, as would be the usual solution on Unix systems, is not appropriate. |
Note that in some language implementations it may not be possible to disconnect from the terminal, and instead the process needs to be started with stdout (and stdin) redirected to files before program start. If that is the case then a helper program to set up this redirection should be written in the language itself. A shell wrapper, as would be the usual solution on Unix systems, is not appropriate. |
||
=={{header|BASIC}}== |
|||
==={{header|QB64}}=== |
|||
<lang QB64>'Metacommands and Statements for closing console or window |
|||
'$Console 'Closes the console but does not close the main window, used for whole program run |
|||
'_Console Off 'Closes console but does not close main window, used for portion of a program run with _Console On |
|||
'_ScreenHide 'Closes main windowm used for a portion of a program run with _ScreenShow |
|||
$ScreenHide 'Closes main window, used for whole program run |
|||
Open "/home/user/Documents/myDaemon.log" For Append As #1 'Fully qualified file path for output |
|||
'Open "./myDaemon.log" For Append As #1 'Relative file path for output |
|||
For i% = 1 To 5 'So this doesn't run ad infinitum |
|||
Print #1, Time$ + " - Running" 'Prints to the file previously opened the current system time (HH:MM:SS) and a note |
|||
Sleep 1 'Waits 1 second |
|||
Next i% |
|||
Close #1 'Closes the file previously opened for writing |
|||
System |
|||
</lang> |
|||
{{out}} |
|||
<pre>19:02:23 - Running |
|||
09:02:24 - Running |
|||
09:02:25 - Running |
|||
09:02:26 - Running |
|||
09:02:27 - Running</pre> |
|||
=={{header|C}}== |
=={{header|C}}== |