NAME

submit - submit a unix command


SYNOPSIS

submit -l log_file -i pid_file -e exit_code_file unix_command

submit help=y|n

kill -- -submit process ID


DESCRIPTION

submit allows you to issue a command to the operating system, let it run independently, and immediately return the control to the calling process.

The calling process is able to check the existence of the process, and exiting status, and the log via files specified.

submit can be used in following situations:

When you want to issue a long running process and exit from the terminal voluntarily, or you fear that the connection to the server you want to run the process is not reliable.

When you want to run multiple processes in parallel, and need to check the status of the processes (see mrun program).

Submit is similar to nohup(1) and putting a process in background (nohup unix_command &). But submit makes it possible, or easier to check the existence and status of the process for unix_command, especially for programming purpose.

The mechanisms used by submit and nohup are completely different.

Nohup blocks the SIGHUP to the process running unix_command. We need to put the process in background in order to return to the calling process.

Submit uses double fock() technique, Submit spawns a child process and then immediately returns to the calling program. The child process is then adopted by init and thus runs indepedent from the calling program. The child spawns another child process (grand child) that runs the the unix_command. The child process waits for unix_command to complete and reaping the status. The child process is promoted to be the process group leader, so we can kill the processes as a group.


OPTIONS

-l log_file

The stdout and stderr of the unix_command is saved in a self-cleaning log file specified by this option. The default is HOME_DIR/submit.log for normal users, and /opt/local/log/submit.log for root user. The log file is kept for a maximum number of lines.

The process ID and exit code are also saved in log_file, but they can be save seperately for easier processing programatically.

-i pid_file

The submit's child process ID is used this file.

-e exit_code_file

The exit code of process for unix_command.

unix_command

Specify a Unix command. Shell special characters need to escaped so they can be seen by Perl's system() call.


EXAMPLES

  $ submit "make > make.log"
  $ submit make \> make.log
  $ submit 'make CC="gcc" CFLAGS="-g -O2"'
  $ submit make CC=\"gcc\" CFLAGS=\"-g -O2\"
  $ submit make\; make install
  $ rsh machine "submit command"
  $ submit sleep 120
  $ mwang submitting sleep 120, pid=4939
  $ ptree 4939
  4939  /usr/bin/perl -w /usr/local/bin/submit sleep 120
    4948  sleep 120
  $ kill -- -4939


SEE ALSO

mrun help=y, bk.oracle.

Advanced Programming in the Unix Environment, by W. Richard Stevens (Addison-Wesley, 1992).


AUTHOR

Michael Wang <xw73@columbia.edu>, 1998-2002, with help from others, acknowledged in code comments.

Michael Sullivan, 1993.

This is free software. You may copy or redistribute it under the same terms as Perl. However, if you modify it, you need to send the modification to the current author via email.