Linux crontab定时任务

配置

1.编写第一个shell文件 hello.sh
vim hello.sh

#!/bin/bash
echo "hello word !!" >> /www/hello.txt

2、通过chmod命令赋予该脚本的执行权限
chmod 755 hello.sh
3、新增调度任务(5分钟执行一次)
vim /etc/crontab

*/5 * * * * root /www/hello.sh

crond服务

service crond start //启动服务
service crond stop //关闭服务
service crond restart //重启服务
service crond reload //重新载入配置
service crond status //查看服务状态

https://blog.csdn.net/weixin_36211536/article/details/116990991

报错解决

postfix报错postfix: fatal: parameter inet_interfaces: no local interface found for ::1
==》vim /etc/postfix/main.cf
发现配置为:
inet_interfaces = localhost
inet_protocols = all
改成:
inet_interfaces = all
inet_protocols = all
重新启动
service postfix start

crond运行python 文件报错:SyntaxError: invalid syntax

crond运行环境变量与手动执行不同,建议crontab和脚本里无论是命令还是文件路径都用绝对路径
另外,source /etc/profile(这个可以加到脚本里)
https://blog.csdn.net/ranran0224/article/details/76119524

文件过大,crond停止执行

postdrop: warning: uid=0: File too large
sendmail: fatal: root(0): message file too big
postdrop: warning: uid=0: File too large
sendmail: fatal: root(0): message file too big

js 调试、定时器、重新加载页面、自动更新js

代码调试之console.log:https://www.jb51.net/article/93941.htm
js定时器:https://blog.csdn.net/ScumStudy/article/details/121003895
js重新加载页面的方法:https://www.jb51.net/article/113710.htm
在html中,给引用的js文件自动添加版本号,去掉js缓存:https://blog.csdn.net/xiaojin21cen/article/details/86495767
js实现股票实时刷新数据案例:https://www.jb51.net/article/113710.htm

mysql 开发-存储序列化二进制字符串

官方文档:https://www.mysqlzh.com/doc/194.html

首先最重要的要使用二进制类型存储数据,MySQL支持二进制的类型有Blob

MySQL的四种BLOB类型

类型 大小(单位:字节)
TinyBlob 最大 255
Blob 最大 65K
MediumBlob 最大 16M
LongBlob 最大 4G

相关函数

存储序列化二进制字符串:
mysql_real_escape_string() ==> 连接二进制字符串
int mysql_real_query(MYSQL mysql, const char query, unsigned long length) ==> 存储and查询
mysql_num_fields(result); ==> 获取结果row 字段个数
mysql_fetch_lengths(result); ==> 获取结果row 字符长度数组

参考:https://blog.csdn.net/nibiru_holmes/article/details/51387047

linux – sftp, scp, rz, sz(文件传输命令)

1. sftp

Secure Ftp 是一个基于SSH安全协议的文件传输管理工具。由于它是基于SSH的,会在传输过程中对用户的密码、数据等敏感信息进行加密,因此可以有效的防止用户信息在传输的过程中被窃取,比FTP有更高的安全性。在功能方面与FTP很类似,不仅可以传输文件数据,而且可以进行远程的文件管理(如建立,删除,查看文件列表等操作)。Sftp与ftp虽然只有一字之差,但基于的传输协议却是不同的。因此不能用sftp client去连接ftp server 也不能用 ftp client 去连接 sftp server。
建立连接:sftp user@host
从本地上传文件:put localpath
下载文件:get remotepath
切换远程目录:cd
显示远程工作目录:pwd
建立远程目录:mkdir
与远程相对于的本地操作,只需再命令前加上“l”即可
如:lcd lpwd lmkdir

参考:https://blog.csdn.net/tjcwt2011/article/details/120779486

pyhton3用命令python -m http.server 搭建服务器

(base) [root@VM-20-16-centos ~]# python -m http.server --help
usage: server.py [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port]

positional arguments:
  port                  Specify alternate port [default: 8000]

optional arguments:
  -h, --help            show this help message and exit
  --cgi                 Run as CGI Server
  --bind ADDRESS, -b ADDRESS
                        Specify alternate bind address [default: all
                        interfaces]
  --directory DIRECTORY, -d DIRECTORY
                        Specify alternative directory [default:current
                        directory]