cron

记一次 Linux 被入侵,服务器变“矿机”全过程

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-30 09:33:34
程序员的成长之路 互联网/程序员/成长/职场 关注 阅读本文大概需要 4.2 分钟。 周一早上刚到办公室,就听到同事说有一台服务器登陆不上了,我也没放在心上,继续边吃早点,边看币价是不是又跌了。 不一会运维的同事也到了,气喘吁吁的说:我们有台服务器被阿里云冻结了,理由:对外恶意发包。 我放下酸菜馅的包子,SSH 连了一下,被拒绝了,问了下默认的 22 端口被封了。 让运维的同事把端口改了一下,立马连上去,顺便看了一下登录名 :root,还有不足 8 位的小白密码,心里一凉:被黑了! 查找线索 服务器系统 CentOS 6.X,部署了 Nginx,Tomcat,Redis 等应用,上来先把数据库全备份到本地,然后 Top 命令看了一下,有 2 个 99% 的同名进程还在运行,叫 gpg-agentd。 Google 了一下 GPG,结果是: GPG 提供的 gpg-agent 提供了对 SSH 协议的支持,这个功能可以大大简化密钥的管理工作。 看起来像是一个很正经的程序嘛,但仔细再看看服务器上的进程后面还跟着一个字母 d,伪装的很好,让人想起来 Windows 上各种看起来像 svchost.exe 的病毒。 继续排查: ps eho command -p 23374netstat -pan | grep 23374 查看 pid:23374 进程启动路径和网络状况,也就是来到了图

Syntax error near unexpected token `newline' in cPanel

孤人 提交于 2021-01-29 20:08:07
问题 I am trying to back up my database in Laravel using Spatie package. Every thing worked fine till 31 Decemeber 2020 and in New Year my cron job stoped working. I don't know what happened, but on my cPanel mail I am receiving this email: /usr/local/cpanel/bin/jailshell: -c: line 0: syntax error near unexpected token `newline' /usr/local/cpanel/bin/jailshell: -c: line 0: `/usr/local/bin/php /home2/scoopscr/public_html/artisan backup:run 1>> ' and this is the cron job I am applying: /usr/local

Cron job for generate Go Access report not working

拈花ヽ惹草 提交于 2021-01-29 18:29:40
问题 In my root crontab ( sudo crontab -e ) I have this job to generate Go Access log reports: * * * * * goaccess /var/log/nginx/access.log -o /home/me/some/path/report.html It works just fine. I also have this job to generate a report that spans multiple days: * * * * * sudo zcat -f /var/log/nginx/access.log* | goaccess -o /home/me/some/path/bigger_report.html Cron says it runs but it doesn't actually seem to run. I've looked around and tried a bunch of things (including following the list here -

Bash script is not running in my crontab (AWS ec2 linux)

时光总嘲笑我的痴心妄想 提交于 2021-01-29 14:56:31
问题 Following has been set to crontab: PATH=/sbin:/bin:/usr/sbin:/usr/bin * * * * * /var/www/NODE_PROJECT/cron-bash.sh cron-bash.sh has following code : #!/bin/bash echo "Job initiated !!!" node app.js I can see error log as CROND[17889]: (root) CMD (/var/www/NODE_PROJECT/cron-bash.sh) 回答1: First you should be sure your script is executable chmod +rx /var/www/NODE_PROJECT/cron-bash.sh then add source to you bash profile and absolute paths #!/bin/bash source ~/.bash_profile #or .bashrc echo "Job

“Connect timeout on endpoint URL” when running cron job

假如想象 提交于 2021-01-29 08:54:26
问题 I have set a crontab file to run a Python script that creates an JSON file and writes it to an S3 bucket. It runs as expected when executed from the command line, but when I run it as a cron job, I get the following error: botocore.exceptions.ConnectTimeoutError: Connect timeout on endpoint URL This results from the following lines of code in the script: import boto3 def main(): # Create EC2 client and get EC2 response ec2 = boto3.client('ec2') response = ec2.describe_instances() My guess is

Cron Job in Ubuntu creating multiple instances

戏子无情 提交于 2021-01-29 08:33:53
问题 Please Help. I have created a API which will call a sms API and send the sms. My code flow is like - The API(Mobile Number as parameter) hit my code - I have storing the mobile in my database and then dispatch a job. in my ubuntu serve I have added this line in crontab -e editor * * * * * cd /var/www/html/project&& php /var/www/html/project/artisan schedule:run >> /dev/null 2>&1 and my scheduler in laravel is $schedule->exec('php artisan queue:work')->everyMinute(); and I tried sudo service

Getting crontab on MAC to run anaconda installed python script (module not found)

自闭症网瘾萝莉.ら 提交于 2021-01-29 05:42:35
问题 I am trying to set up crontab for a script written in python which is intalled via Anaconda. The simple .py runs (it just loads a module for a demo) and can be run in terminal with python a.py . The problem is getting crontab the path for python and imported modules. I have been trying to set the PATH and PYTHONPATh to the python directory and also where pandas is located. I think this is a env issue but have no idea what that means. Any ideas? The crontab is: SHELL=/bin/sh PYTHONPATH=/Users

PHP Cron job to backup to Google Drive

て烟熏妆下的殇ゞ 提交于 2021-01-29 05:24:28
问题 I am trying to set up a cron job that will back up various files from my server to Google Drive. I have looked at many solutions and none seem to work! The closest I have got (using oAuth) is this: <?php /* * Copyright 2011 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law

Cron job fails while executing python script - keyError

不羁岁月 提交于 2021-01-29 05:07:21
问题 My cron job: */2 * * * * /usr/local/bin/python3.7 /path/to/python/script.py >> /path/to/my/log.txt 2>&1 each time this job runs it generates this error in my log.txt : % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 100 62 100 62 0 0 40 0 0:00:01 0:00:01 --:--:-- 40 Traceback (most recent call last): File "/path/to/python/script.py", line 16, in <module

python-notify module & cron: gio.Error

与世无争的帅哥 提交于 2021-01-29 04:55:52
问题 I'm asking some help to show notifications using python-crontab, because everything I've tried do not work. The display is not initilised when the script is launched by cron. When I start it manually, that's work. The codes I've tried: #!/usr/bin/env python # coding: utf8 import subprocess import os #os.environ.setdefault("XAUTHORITY", "/home/guillaume" + "/.Xauthority") #os.environ.setdefault('DISPLAY', ':0.0') # do not work #os.environ['DISPLAY'] = ':0.0' # do not work print = os.environ