blob: a8288ccefde1ae5daa549832bde8a12c91537262 (
plain)
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
|
#!/bin/sh
#
# Run the command to get emails, and record its PID, which is used
# to kill the program before run it again.
# This is an workaround to solve the stuck issue with `offlineimap`.
#
# Command to get emails
GET_CMD="offlineimap -o -1"
# PID file
PID_FILE="${HOME}/.cache/get_mail.pid"
# Log file
LOG_FILE="${HOME}/.cache/get_mail.log"
# Kill the previous process at first.
# For `offlineimap`, it sometimes just stucks ...
if [ -e "${PID_FILE}" ]; then
kill -SIGKILL `cat ${PID_FILE}`
rm ${PID_FILE}
fi
if [ -e "${LOG_FILE}" ]; then
mv ${LOG_FILE} ${LOG_FILE}.old
fi
${GET_CMD} > ${LOG_FILE} 2>&1 &
echo $! > ${PID_FILE}
|