如果:
如果:
0 22 * * * tar -zcPf /data/`date "+%Y%m%d"`.tar.gz /data/*.json --remove-files
# P是为了允许绝对路径,否则有警告,虽然不影响执行。
后补:
如果文件很多,会提示shell命令太长的错误,所以还是对着文件夹比较好。
1. 问题
docker容器日志导致主机磁盘空间满了。docker logs -f container_name噼里啪啦一大堆,很占用空间,不用的日志可以清理掉了。
2. 解决方法
2.1 找出Docker容器日志
在linux上,容器日志一般存放在/var/lib/docker/containers/container_id/下面, 以json.log结尾的文件(业务日志)很大,查看各个日志文件大小的脚本docker_log_size.sh,内容如下:
既然ping一个IP,最大的延迟一般也就500ms左右,那为何不批量ping当traceroute用呢?不都是发包嘛。
所以,对于一个traceroute 将近10秒甚至40秒才能拿到的路径,py程序拆分后,直接多线程traceroute参数设置后(套多进程、后面可以优化为直接多个线程)发出去,不香吗?
部分代码:
import urllib2 from multiprocessing.dummy import Pool as ThreadPool import time import os ip = '170.110.229.208' def tracert((ip, f)): os.system('traceroute -w 1 -n -I -q 1 {} -f {} -m {}'.format(ip, f, f)) urls = [ (ip, '1'), (ip, '3'), (ip, '5'), (ip, '7'), (ip, '9'), (ip, '11'), (ip, '13'), (ip, '15'), (ip, '17'), (ip, '19'), (ip, '21'), (ip, '23'), (ip, '25'), (ip, '27'), (ip, '29'), (ip, '2'), (ip, '4'), (ip, '6'), (ip, '8'), (ip, '10'), (ip, '12'), (ip, '14'), (ip, '16'), (ip, '18'), (ip, '20'), (ip, '22'), (ip, '24'), (ip, '26'), (ip, '28'), (ip, '30') ] # Make the Pool of workers pool = ThreadPool(40) # Open the urls in their own threads # and return the results start = time.time() results = pool.map(tracert, urls) #close the pool and wait for the work to finish pool.close() pool.join() end = time.time() print(end - start)
我也是总是没搞懂,为啥网上有99%的教程都是让把java的环境变量往profile里写。
能不能用,当然能。问题是,请看原文:
# /etc/profile # System wide environment and startup programs, for login setup # Functions and aliases go in /etc/bashrc # It's NOT a good idea to change this file unless you know what you # are doing. It's much better to create a custom.sh shell script in # /etc/profile.d/ to make custom changes to your environment, as this # will prevent the need for merging in future updates. pathmunge () { case ":${PATH}:" in *:"$1":*) ;; *) if [ "$2" = "after" ] ; then PATH=$PATH:$1 else PATH=$1:$PATH fi esac } if [ -x /usr/bin/id ]; then if [ -z "$EUID" ]; then # ksh workaround EUID=`/usr/bin/id -u` UID=`/usr/bin/id -ru` fi USER="`/usr/bin/id -un`" LOGNAME=$USER MAIL="/var/spool/mail/$USER" fi # Path manipulation if [ "$EUID" = "0" ]; then pathmunge /usr/sbin pathmunge /usr/local/sbin else pathmunge /usr/local/sbin after pathmunge /usr/sbin after fi HOSTNAME=`/usr/bin/hostname 2>/dev/null` HISTSIZE=1000 if [ "$HISTCONTROL" = "ignorespace" ] ; then export HISTCONTROL=ignoreboth else export HISTCONTROL=ignoredups fi export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL # By default, we want umask to get set. This sets it for login shell # Current threshold for system reserved uid/gids is 200 # You could check uidgid reservation validity in # /usr/share/doc/setup-*/uidgid file if [ $UID -gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ]; then umask 002 else umask 022 fi for i in /etc/profile.d/*.sh ; do if [ -r "$i" ]; then if [ "${-#*i}" != "$-" ]; then . "$i" else . "$i" >/dev/null fi fi done unset i unset -f pathmunge
其实,springboot读取xml已经够“非主流”了,因为一看springboot那架势,就是想抛弃xml的节奏,只不过各种原因提供了兼容。
如果实在想在springboot里引用xml创建的bean,那么使用类似如下方式即可:
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.ImportResource; @Configuration @ImportResource(locations={"classpath:client.xml"}) public class ConfigClass { }
Powered By Z-BlogPHP 1.7.2
© 2013-2022 nohup.net , All Rights Reserved. 豫ICP备20020372号-1