linux知识问答

目录

1. systemd是什么?

2.如何利用systemd, 让自己写的程序运行出错后,可以自动重启

   1)在/lib/systemd/system, 下面创建文件,gogs.service

 2)操作service


tem, 下面创建文件,gogs.service

 2)


1. systemd是什么?

  参考:http://www.ruanyifeng.com/blog/2016/03/systemd-tutorial-commands.html

   systemd相对于传统的init, 是操作系统启动的首个进程,然后启动systemd管理的各个服务,d指的是daemon, 守护进程

每个服务,存放在/lib/systemd/system/, 下面,sytemctl enable后,会在/etc/systemd/system/下面创建一个软链接指向这个服务

2.如何利用systemd, 让自己写的程序运行出错后,可以自动重启

   1)在/lib/systemd/system, 下面创建文件,gogs.service

   

[Unit]
Description=Gogs
After=network.target
 
[Service]
# Modify these two values and uncomment them if you have
# repos with lots of files and get an HTTP error 500 because
# of that
###
#LimitMEMLOCK=infinity
#LimitNOFILE=65535
Type=forking
User=gogs
Group=gogs
WorkingDirectory=/usr/local/git/gogs
ExecStart=/bin/sh /usr/local/git/gogs/gogs.sh
Restart=always
Environment=USER=gogs HOME=/home/gogs
 
# Some distributions may not support these hardening directives. If you cannot start the service due
# to an unknown option, comment out the ones not supported by your version of systemd.
#ProtectSystem=full
#PrivateDevices=yes
#PrivateTmp=yes
#NoNewPrivileges=true
 
[Install]
WantedBy=multi-user.target

————————————————
版权声明:本文为CSDN博主「码农农码一生」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/chenhao_c_h/article/details/92064209

 2)操作service

systemctl daemon-reload
systemctl enable gogs.service
systemctl start gogs.service
  查看 sercvice 状态
systemctl status gogs.service

3. conda activate 进入一个环境,如何退出这个环境?

  conda deactivate  

4.package config, libavformat.pc, 这种文件是做什么用的?

libavformat.pc:
prefix=/home/silva/ffmpeg_build
exec_prefix=${prefix}
libdir=/home/silva/ffmpeg_build/lib
includedir=/home/silva/ffmpeg_build/include

Name: libavformat
Description: FFmpeg container format library
Version: 58.29.100
Requires:
Requires.private: libavcodec >= 58.54.100, libswresample >= 3.5.100, libavutil >= 56.31.100
Conflicts:
Libs: -L${libdir}  -lavformat
Libs.private: -lm -lz
Cflags: -I${includedir}

 这个文件指的是本库,如果谁编译要依赖,那么需要定义的一些库、包含路径变量,以及依赖哪些库及版本。编写的语法,使用pkg-config 工具(apt install pkg-config)规定的语法

5.cmake里面如何使用libavformat.pc文件?

  export PKG_CONFIG_PATH= /home/silva/ffmpeg_build/lib/pkgconfig/;$PKG_CONFIG_PATH

6.如何查看,编辑定时任务?

   crontab -l ; crontab -e

   1)编辑后,一定要restart crontab, 否则不执行

    2)不要加root, 和/etc/crontab里面不一样

   3)一定要看log, /var/log/syslog, 用执行的命令搜索

7.查一个文件是否有重复行,有多少?

https://stackoverflow.com/questions/6712437/find-duplicate-lines-in-a-file-and-count-how-many-time-each-line-was-duplicated

sort FILE | uniq -cd

8. pip install --user psutil, 安装目录在哪里? pip install --system psutil 安装在那里?

  前者在用户目录/home/silva/.local/,  后者在/usr/local/lib/python2.7/...

9.查看程序运行时候加载的动态库的过程

LD_DEBUG=help cat
LD_DEBUG=libs cat
LD_DEBUG=all cat

10. 压缩文件夹,并固定大小切割

tar -cf - /mnt/d/plate_images | split -b 15G -d -a 3 - plate_images.tar.

 

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值