One often-overlooked easy way is to do the install over a serial port. That assumes the machine has a serial port, which is not always the case.
I know, you will say "but my machine doesn't do a serial port console". That doesn't matter. There are two ways to tell OpenBSD to use a serial console, the first, most useful in doing a fresh install from a CD is to use the boot loader:
>> OpenBSD/amd64 BOOT 3.23
boot> stty com0 9600
com0: 9600 baud
boot> set tty com0
switching console to com0
>> OpenBSD/amd64 BOOT 3.23
boot> boot
The second is to put these same parameters in /etc/boot.conf
.
# cat /etc/boot.conf
stty com0 9600
set tty com0
Then you can just log your terminal to a file, or cut and paste from putty, etc. I have some machines that "don't do serial consoles" booting this way, and unless there is a boot failure on the BIOS level, it works great.
If you are using tip
, you can start recording a session by setting the variable script
. You set a variable in tip by issuing ~
s
.
kellogg# tip tty03
connected
~[set] script
The default file name is tip.record
. You can change that name by setting the record
variable. The default recording includes non-printable characters, you can stop tip
from doing that by setting the beautify
variable.
You can also create a .tiprc
file in your home directory to set these variables for you on any tip session.
set script
set beautify
set record=/tmp/tip.txt
Use this syntax in the cronjob:
* * */3 * * root /bin/bash /opt/db_maintain/run.sh
You used source
. That is a shell builtin command from bash
. Therefore it can only be executed inside a bash
shell or via a bash
shell. The crontab just executes binaries, not shell commands. So you have to call a binary (/bin/bash
), preferably by its abolute path.
Best Answer
I’ve investigated the source as to how cron handles mailing the output from its jobs:
cron(8)
sets up stdout and stderr of the running job and pipes it directly intomail(1)
, not leaving any temporary files. Look indo_command.c
around line 411 (1).mail(1)
needs to fully ready its stdin, since it needs the headers. It opens a temporary file (usually/tmp/mail-R…
), but removes it right away, as not to leave traces. Loøk incollect.c
at line 83 (2).In any case, there seems to be deliberate effort not to leave an interceptible temporary file lying around. If you need (or want) to intercept what’s going on in a long-running cronjob, you have to set up a temporary file yourself.
My suggestion at this point is to e.g. add
tee $HOME/cronjob.out
to your cronjob, which captures a copy of your job’s output in a safe place.