Uvcron

From Pickwiki
Revision as of 12:11, 21 December 2007 by Rex Gozar (talk) (* added 'disadvantage using PHANTOM')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

HomePage>>SourceCode>>BasicSource>>uvcron

uvcron.c

by Dave Church

This C program changes the process group id for a Universe cron job.

Clifton Oliver: [The process group id] is used to determine the id of the printer memory segment for the process. If you have two UV processes with the same pgid, they end up sharing the memory segment. This is where your MFILE structures are stored (rotating file pool), among other things. Pointers get mixed up, and you end up getting some file's data written into a completely different file, usually corrupting the group or even the file header, depending on how angry the computer gods are that day.

/* This c routine can be used to start universe processes 
   in cron or at.  Normally only one process can run at a 
   time because they use the same printer memory segment. 
   simply replace the 'uv' command with 'uvcron' for example: 
   uvcron 'BATCH-REPORT1' > dave.mail */

#define UCB 0  /* set to 0 for System V or 1 for Berkeley */

main(argc, argv, envp)
int argc;
char *argv[], *envp[];
{
#if UCB 
   (void)setpgrp(0, getpid());
#else 
   (void)setpgrp();
#endif

   /* CHANGE PATH TO MATCH YOUR INSTALLATION */
   (void)execve("/u1/uv/bin/uv", argv, envp);

   /* We should never come back here */
   printf("exec failed\n");
   exit(-1); 
}

Note that a common workaround is to use PHANTOM commands in cron, e.g.:

0 1 * * * /u1/uv/bin/uv "PHANTOM BATCH-REPORT1"

Perry Taylor: One disadvantage to using PHANTOM are the challenges required to retrieve the output from the program. For example, suppose you needed to get some piece of data from Universe to use in a shell script, say the email address to which to mail a report. The BASIC program MAILTO.LOOKUP does the lookup and CRT's the email address. Using uvcron you could do the following...

mail_to=$(cd $your_uv_account_dir && uvcron 'RUN BP MAILTO.LOOKUP')

This would be much more difficult to retrieve if MAILTO.LOOKUP were run as a PHANTOM.

http://www.autopower.com/rgozar/pixel.gif