首页
轻听2.0常见问题
轻听APP2.0
关于
Search
1
GO程序打包至Linux服务器运行
1,009 阅读
2
SpringBoot2.7.9+Mybatis-Plus3.5.3.1+ShardingSphere-JDBC5.3.1实现分库分表
526 阅读
3
完美解决方案-雪花算法ID到前端之后精度丢失问题
413 阅读
4
mysql 让清空表且自增的id重新从0开始的命令
403 阅读
5
template.ParseFiles文件路径踩坑
364 阅读
Git
Java
SQL
区块链
网站搭建技术
SpringBoot
thymeleaf
Vue
GO
实用软件
登录
/
注册
Search
canace
累计撰写
23
篇文章
累计收到
2
条评论
首页
栏目
Git
Java
SQL
区块链
网站搭建技术
SpringBoot
thymeleaf
Vue
GO
实用软件
页面
轻听2.0常见问题
轻听APP2.0
关于
搜索到
3
篇与
GO
的结果
2022-02-20
分割nohup文件脚本
#!/bin/bash this_path="/www/wwwroot/xxxxx/" #宝塔文件脚本目录地址 current_date=`date -d "-1 day" "+%Y%m%d"` #列出时间 cd $this_path echo $this_path echo $current_date do_split () { [ ! -d logs ] && mkdir -p logs split -b 3m -d -a 4 ./nohup.out ./logs/nohup-${current_date} if [ $? -eq 0 ];then echo "Split is finished!" else echo "Split is Failed!" exit 1 fi } do_del_log() { find ./logs -type f -ctime +7 | xargs rm -rf #清理7天前创建的日志 cat /dev/null > nohup.out #清空当前目录的nohup.out文件 } if do_split ;then do_del_log echo "nohup is split Success" else echo "nohup is split Failure" exit 2 fi将其在宝塔的计划任务中执行shell脚本即可原脚本:#!/bin/bash # Author: Ljohn # Last Update: 2018.02.24 # Description: nohup.out 日志分割 this_path=$(cd `dirname $0`;pwd) #根据脚本所在路径 current_date=`date -d "-1 day" "+%Y%m%d"` #列出时间 cd $this_path echo $this_path echo $current_date do_split () { [ ! -d logs ] && mkdir -p logs split -b 3m -d -a 4 ./nohup.out ./logs/nohup-${current_date} #切分3兆每块至logs文件中,格式为:nohup-xxxxxxxxxx if [ $? -eq 0 ];then echo "Split is finished!" else echo "Split is Failed!" exit 1 fi } do_del_log() { find ./logs -type f -ctime +7 | xargs rm -rf #清理7天前创建的日志 cat /dev/null > nohup.out #清空当前目录的nohup.out文件 } if do_split ;then do_del_log echo "nohup is split Success" else echo "nohup is split Failure" exit 2 fi # crontab -e 添加定时任务:每周第一天的1点执行一次 #0 1 * * */1 /server/scripts/clearNohup.sh &>/dev/null
2022年02月20日
260 阅读
0 评论
0 点赞
2022-01-27
template.ParseFiles文件路径踩坑
GO的template.ParseFiles用于读取本地的html文件,但是它好像不支持相对路径,需要使用绝对路径。可以使用下面方法:os.Getwd() 可用于返回项目的根工作目录,然后与模板文件的内部路径连接:// Working Directory wd, err := os.Getwd() if err != nil { log.Fatal(err) } // Template tpl, err := template.ParseFiles(wd + "/templates/index.html")
2022年01月27日
364 阅读
0 评论
0 点赞
2022-01-20
GO程序打包至Linux服务器运行
一、本地编译Golang程序cmd控制台到main.go文件目录下,执行:set GOARCH=amd64 set GOOS=linux go build main.go此时会生成一个没有后缀的二进制文件main二、上传Golang二进制文件到Linux服务器将该文件放入linux系统某个文件夹下赋予权限chmod 777 main最后执行 ./main 就行了。如果想让项目在后台执行:执行 nohup ./main & ,这样就可以程序在后台运行了。
2022年01月20日
1,009 阅读
0 评论
0 点赞