-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbk
More file actions
executable file
·37 lines (34 loc) · 1010 Bytes
/
bk
File metadata and controls
executable file
·37 lines (34 loc) · 1010 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
# Run process in background
# Immune from logoffs -- output to file log
#If you want colors
export TERM=xterm-256color
RED=$(tput setaf 1)
GREEN=$(tput setaf 2)
YELLOW=$(tput setaf 3)
BLUE=$(tput setaf 4)
PINK=$(tput setaf 5)
BLACK=$(tput init)
NC=$(tput sgr0)
INFC="${YELLOW}"
#Remove previous log if there is one
(test -f "$*.log") && rm "$*.log"
(
if [ "$USER" = "ranza" ]; then
echo "Custom LD_LIBRARY_PATH"
export LD_LIBRARY_PATH=/home/ranza/gsl/lib
LC_ALL=C
fi
echo "${PINK}Date:${GREEN} $(date)"
echo "${PINK}Command:${GREEN} $*${NC}"
nice nohup "$@"
echo "${PINK}Completed: ${GREEN}$(date)${NC}"
echo
) >>${LOGFILE:=$*.log} 2>&1 &
#Show the lines of the log after 1s to see how it is working
slper=1
sleep $slper
echo "${INFC}----------------------- \"${GREEN}$*.log${INFC}\" file after ${slper}s -----------------------"
cat "$*.log"
echo "${INFC}----------------------- \"${GREEN}$*.log${INFC}\" file END -----------------------"
echo