I've only written a blog full of anime material, I will also post it as a memorandum.
In the first place, the reason for trying to create a periodical execution process was I'm doing the same thing every week on a website, can you do it automatically? Because of the request.
So
Python package management system installation
yum install python-pip
Python Selenium installation
pip install selenium
Firefox installation
yum install firefox
Xvfb installation
yum install xorg-x11-server-Xvfb
Create Xvfb auto-start service
vi /etc/init.d/xvfb
/etc/init.d/xvfb
#!/bin/bash
#
# chkconfig: - 91 35
# description: Xvfb
# Source function library.
. /etc/init.d/functions
# Xvfb define
readonly XVFB=/usr/bin/Xvfb
readonly XVFB_STATUS=":1 -screen 0 1366x768x24"
readonly XVFB_PID_FILE=/var/run/xvfb.pid
readonly XVFB_SERVICE=$"Xvfb"
retval=0
start() {
if [ -e ${XVFB_PID_FILE} ]; then
action $"Starting ${XVFB_SERVICE}: " /bin/false
echo "${XVFB_SERVICE}Is already running."
else
action $"Starting ${XVFB_SERVICE}: " /bin/true
${XVFB} ${XVFB_STATUS} > /dev/null 2>&1 &
echo $! > ${XVFB_PID_FILE}
fi
}
stop() {
if [ -e ${XVFB_PID_FILE} ]; then
action $"Stopping ${XVFB_SERVICE}: " /bin/true
pid=`cat ${XVFB_PID_FILE}`
test ! -z $pid && kill $pid && rm -f ${XVFB_PID_FILE}
else
action $"Stopping ${XVFB_SERVICE}: " /bin/false
echo "${XVFB_SERVICE}Is not running."
fi
}
status() {
if [ -e ${XVFB_PID_FILE} ]; then
echo "${XVFB_SERVICE} (pid `cat ${XVFB_PID_FILE}`)Is running..."
else
echo "${XVFB_SERVICE}Is not running."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
sleep 1
start
;;
status)
status
;;
*)
echo $"Usage: $0 {start|stop|restart|status}"
retval=1
esac
exit ${retval}
Xvfb auto-start service settings
chmod 755 /etc/init.d/xvfb
chkconfig --add xvfb
chkconfig --level 3 xvfb on
Xvfb reboot
/etc/init.d/xvfb restart
Periodic execution process creation
crontab -e
cron
#Specify e-mail address for checking cron execution result
[email protected]
# /home/kotanbo/test.The py part specifies the uploaded test case
#The following is regularly executed at 9 o'clock on Sunday
0 9 * * 0 export DISPLAY=localhost:1.0; python /home/kotanbo/test.py
cron restart
/etc/init.d/crond restart
Ruby + selenium-webdriver in Linux CUI environment Xvfb startup script [Automatically start selenium server on centos](http://hironoki.com/blog/2011/10/28/centos%E3%81%A7selenium%E3%82%B5%E3%83%BC%E3%83%90 % E3% 83% BC% E8% 87% AA% E5% 8B% 95% E8% B5% B7% E5% 8B% 95 /)
2017/04/27
The latest firefox and selenium probably won't work with the above. I have described the contents of the newly constructed environment, so please also check it out. => I made a periodical execution process with CentOS7, Selenium, Python and Chrome
Recommended Posts