$key = QiyuKey::APPKEY;
$now = time();
$post = [
'appKey' => $key,
'time' => $now,
];
$checksum = sha1(QiyuKey::APPSECRET . md5(json_encode($post)) . $now);
$url = "https://xxx.com/v2/staff/list/new?appKey={$key}&time={$now}&checksum={$checksum}";
$ret = self::httpPost($url, $post);简易验签方案
linux 安全 查看cpu占用
查看CPU占用最高的PHP进程
ps -aux --sort=-%cpu|head -10|grep php
查看内存占用最高的PHP进程
ps -aux --sort=-%mem|head -10|grep php
统计PHP进程数量和平均CPU使用率
ps -aux|grep php|awk '{cpu+=$3;count++} END {print "PHP进程数:",count,"平均CPU使用率:",cpu/count"%"}'
批量干掉进程
pkill -f "addUserBadge clc"
生成随机昵称
public static function getRandNickName()
{
$data = ARandWord::cache(is_test_ab() ? 100 : 86400 * 3)
->field('type,id')
->select();
$rule = ARandWord::NICK_RULE;
$rand_ids = [];
$ids = [];
$rangeData = [];
$size = 3; //生成3个昵称验证去重
foreach ($data as $item) {
$rangeData[$item['type']][] = $item['id'];
}
foreach ($rule as $type) {
$arr = $rangeData[$type];
$id = [];
for ($j = 0;$j<$size;$j++) {
$id[] = $arr[array_rand($arr)];
}
$rand_ids[$type] = $id;
$ids = array_merge($ids, $id);
}
$keyWords = ARandWord::whereIn('id', $ids)->column('name', 'id');
$names = [];
for ($i = 0; $i < $size; $i++) {
$names[] = $keyWords[$rand_ids[1][$i]] . $keyWords[$rand_ids[2][$i]] . '的' . $keyWords[$rand_ids[3][$i]];
}
$db_exit = AMem::where('nickname', 'in', $names)->column('nickname') ?? [];
$last_names = array_diff($names, $db_exit);
if (!empty($last_names)) {
return array_shift($last_names);
} else {
//兜底基本用不上
return '玩家' . StringUtils::getRandomStr('nl', 8);
}
}docker 导入导出镜像
docker save -o hy_dev.tar 2d4567b582e85ded3f
docker load -i hy_dev.tar
docker tag xxx xxx docker 创建cron 定时任务
DockerFile
FROM debian:latest
RUN apt-get update && apt-get install -y cron
COPY cronjobs /etc/cron.d/cronjobs
RUN chmod 0644 /etc/cron.d/cronjobs
RUN touch /var/log/cron.log
CMD cron && tail -f /var/log/cron.log
cronjobs
* * * * * root echo 'cron is running' >> /var/log/cron.log 2>&1
##用文件会出错 deepseek说是少了换行导致的
//创建镜像
docker build -t cron-app .