AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / user-180699

richelliot's questions

Martin Hope
richelliot
Asked: 2016-10-28 02:54:41 +0800 CST

apt-get 因未满足的依赖关系而失败:Breaks、Depends、Recommends - 这一切意味着什么?

  • 0

我试图通过在我的 Ubuntu 12.04 服务器上运行以下命令来修补 Dirty Cow 漏洞:

sudo apt-get update && sudo apt-get dist-upgrade

这会导致以下错误:

The following packages have unmet dependencies:
 lsb-base : Breaks: upstart (< 1.12.1-0ubuntu8)
            Breaks: upstart:i386 (< 1.12.1-0ubuntu8)
 plymouth : Depends: initramfs-tools but it is not going to be installed
            Recommends: plymouth-theme-ubuntu-text but it is not going to be installed or
                        plymouth-theme
 udev : Depends: initramfs-tools (>= 0.92bubuntu63) but it is not going to be installed
        Depends: util-linux (> 2.15~rc2)
E: Error, pkgProblemResolver::Resolve generated breaks, this may be caused by held packages.

我需要做什么才能修复这些错误?

ubuntu packages apt ubuntu-12.04
  • 1 个回答
  • 749 Views
Martin Hope
richelliot
Asked: 2015-06-25 05:45:06 +0800 CST

ec2-automate-backup-awscli.sh - 清除不起作用?

  • 0

我最近实现了一个创建卷快照的脚本。我通过一个 cron 作业运行这个脚本,该作业运行良好,除了删除快照的部分。

当我运行创建快照的命令时,我包含“ -k 3”,它应该用标签标记新创建的快照,表明它应该在三天内被删除。

这是我的 Cron 运行的命令:

sudo sh /home/ubuntu/scripts/ec2-automate-backup-awscli.sh -r eu-west-1 -v "vol-2abaf42s" -k 3 -p -n -c /root/bin/cron-primer.sh -l "os-server"

这是错误输出:

/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 182: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 191: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 21: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 21: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 21: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 21: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 207: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 31: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 48: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 224: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 68: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 73: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 85: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found
Snapshot Purging is Starting Now.
/home/ubuntu/scripts/ec2-automate-backup-awscli.sh: 133: /home/ubuntu/scripts/ec2-automate-backup-awscli.sh: [[: not found

这是我正在使用的脚本:

#!/bin/bash -
# Date: 2014-04-12
# Version 0.10
# License Type: GNU GENERAL PUBLIC LICENSE, Version 3
# Author:
# Colin Johnson / https://github.com/colinbjohnson / [email protected]
# Contributors:
# Alex Corley / https://github.com/anthroprose
# Jon Higgs / https://github.com/jonhiggs
# Mike / https://github.com/eyesis
# Jeff Vogt / https://github.com/jvogt
# Dave Stern / https://github.com/davestern
# Josef / https://github.com/J0s3f
# buckelij / https://github.com/buckelij

#confirms that executables required for succesful script execution are available
prerequisite_check() {
  for prerequisite in basename cut date aws; do
    #use of "hash" chosen as it is a shell builtin and will add programs to hash table, possibly speeding execution. Use of type also considered - open to suggestions.
    hash $prerequisite &> /dev/null
    if [[ $? == 1 ]]; then #has exits with exit status of 70, executable was not found
      echo "In order to use $app_name, the executable \"$prerequisite\" must be installed." 1>&2 ; exit 70
    fi
  done
}

#get_EBS_List gets a list of available EBS instances depending upon the selection_method of EBS selection that is provided by user input
get_EBS_List() {
  case $selection_method in
    volumeid)
      if [[ -z $volumeid ]]; then
        echo "The selection method \"volumeid\" (which is $app_name's default selection_method of operation or requested by using the -s volumeid parameter) requires a volumeid (-v volumeid) for operation. Correct usage is as follows: \"-v vol-6d6a0527\",\"-s volumeid -v vol-6d6a0527\" or \"-v \"vol-6d6a0527 vol-636a0112\"\" if multiple volumes are to be selected." 1>&2 ; exit 64
      fi
      ebs_selection_string="--volume-ids $volumeid"
      ;;
    tag)
      if [[ -z $tag ]]; then
        echo "The selected selection_method \"tag\" (-s tag) requires a valid tag (-t Backup,Values=true) for operation. Correct usage is as follows: \"-s tag -t Backup,Values=true.\"" 1>&2 ; exit 64
      fi
      ebs_selection_string="--filters Name=tag:$tag"
      ;;
    *) echo "If you specify a selection_method (-s selection_method) for selecting EBS volumes you must select either \"volumeid\" (-s volumeid) or \"tag\" (-s tag)." 1>&2 ; exit 64 ;;
  esac
  #creates a list of all ebs volumes that match the selection string from above
  ebs_backup_list=$(aws ec2 describe-volumes --region $region $ebs_selection_string --output text --query 'Volumes[*].VolumeId')
  #takes the output of the previous command 
  ebs_backup_list_result=$(echo $?)
  if [[ $ebs_backup_list_result -gt 0 ]]; then
    echo -e "An error occurred when running ec2-describe-volumes. The error returned is below:\n$ebs_backup_list_complete" 1>&2 ; exit 70
  fi
}

create_EBS_Snapshot_Tags()
{
    #snapshot tags holds all tags that need to be applied to a given snapshot - by aggregating tags we ensure that ec2-create-tags is called only onece
    snapshot_tags=""
    #if $name_tag_create is true then append ec2ab_${ebs_selected}_$current_date to the variable $snapshot_tags
    if $name_tag_create
        then
        snapshot_tags="$snapshot_tags Key=Name,Value=ec2ab_${ebs_selected}_$current_date"
    fi
    #if $hostname_tag_create is true then append --tag InitiatingHost=`hostname -f` to the variable $snapshot_tags
    if $hostname_tag_create
        then
        snapshot_tags="$snapshot_tags Key=InitiatingHost,Value='`hostname -f`'"
    fi
    #if $purge_after_date_fe is true, then append $purge_after_date_fe to the variable $snapshot_tags
    if [[ -n $purge_after_date_fe ]]
        then
        snapshot_tags="$snapshot_tags Key=PurgeAfterFE,Value=$purge_after_date_fe Key=PurgeAllow,Value=true"
    fi

    if [[ -n $label ]]
        then
        snapshot_tags="$snapshot_tags Key=Name,Value=$label"
    fi

    #if $user_tags is true, then append Volume=$ebs_selected and Created=$current_date to the variable $snapshot_tags
    if $user_tags
        then
        snapshot_tags="$snapshot_tags Key=Volume,Value=${ebs_selected} Key=Created,Value=$current_date"
    fi

    #if $snapshot_tags is not zero length then set the tag on the snapshot using aws ec2 create-tags
    if [[ -n $snapshot_tags ]]
        then echo "Tagging Snapshot $ec2_snapshot_resource_id with the following Tags: $snapshot_tags"
        tags_arugment="--tags $snapshot_tags"
        aws_ec2_create_tag_result=`aws ec2 create-tags --resources $ec2_snapshot_resource_id --region $region $tags_arugment --output text 2>&1`
    fi
}


get_date_binary() {
  #$(uname -o) (operating system) would be ideal, but OS X / Darwin does not support to -o option
  #$(uname) on OS X defaults to $(uname -s) and $(uname) on GNU/Linux defaults to $(uname -s)
  uname_result=$(uname)
  case $uname_result in
    Darwin) date_binary="posix" ;;
    FreeBSD) date_binary="posix" ;;
    Linux) date_binary="linux-gnu" ;;
    *) date_binary="unknown" ;;
  esac
}

get_purge_after_date_fe() {
case $purge_after_input in
  #any number of numbers followed by a letter "d" or "days" multiplied by 86400 (number of seconds in a day)
  [0-9]*d) purge_after_value_seconds=$(( ${purge_after_input%?} * 86400 )) ;;
  #any number of numbers followed by a letter "h" or "hours" multiplied by 3600 (number of seconds in an hour)
  [0-9]*h) purge_after_value_seconds=$(( ${purge_after_input%?} * 3600 )) ;;
  #any number of numbers followed by a letter "m" or "minutes" multiplied by 60 (number of seconds in a minute)
  [0-9]*m) purge_after_value_seconds=$(( ${purge_after_input%?} * 60 ));;
  #no trailing digits default is days - multiply by 86400 (number of minutes in a day)
  *) purge_after_value_seconds=$(( $purge_after_input * 86400 ));;
esac
#based on the date_binary variable, the case statement below will determine the method to use to determine "purge_after_days" in the future
case $date_binary in
  linux-gnu) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;;
  posix) echo $(date -v +${purge_after_value_seconds}S -u +%s) ;;
  *) echo $(date -d +${purge_after_value_seconds}sec -u +%s) ;;
esac
}

purge_EBS_Snapshots() {
  # snapshot_purge_allowed is a string containing the SnapshotIDs of snapshots
  # that contain a tag with the key value/pair PurgeAllow=true
  snapshot_purge_allowed=$(aws ec2 describe-snapshots --region $region --filters Name=tag:PurgeAllow,Values=true --output text --query 'Snapshots[*].SnapshotId')

  for snapshot_id_evaluated in $snapshot_purge_allowed; do
    #gets the "PurgeAfterFE" date which is in UTC with UNIX Time format (or xxxxxxxxxx / %s)
    purge_after_fe=$(aws ec2 describe-snapshots --region $region --snapshot-ids $snapshot_id_evaluated --output text | grep ^TAGS.*PurgeAfterFE | cut -f 3)
    #if purge_after_date is not set then we have a problem. Need to alert user.
    if [[ -z $purge_after_fe ]]; then
      #Alerts user to the fact that a Snapshot was found with PurgeAllow=true but with no PurgeAfterFE date.
      echo "Snapshot with the Snapshot ID \"$snapshot_id_evaluated\" has the tag \"PurgeAllow=true\" but does not have a \"PurgeAfterFE=xxxxxxxxxx\" key/value pair. $app_name is unable to determine if $snapshot_id_evaluated should be purged." 1>&2
    else
      # if $purge_after_fe is less than $current_date then
      # PurgeAfterFE is earlier than the current date
      # and the snapshot can be safely purged
      if [[ $purge_after_fe < $current_date ]]; then
        echo "Snapshot \"$snapshot_id_evaluated\" with the PurgeAfterFE date of \"$purge_after_fe\" will be deleted."
        aws_ec2_delete_snapshot_result=$(aws ec2 delete-snapshot --region $region --snapshot-id $snapshot_id_evaluated --output text 2>&1)
      fi
    fi
  done
}

app_name=$(basename $0)
#sets defaults
selection_method="volumeid"
#date_binary allows a user to set the "date" binary that is installed on their system and, therefore, the options that will be given to the date binary to perform date calculations
date_binary=""
#sets the "Name" tag set for a snapshot to false - using "Name" requires that ec2-create-tags be called in addition to ec2-create-snapshot
name_tag_create=true
#sets the "InitiatingHost" tag set for a snapshot to false
hostname_tag_create=false
#sets the user_tags feature to false - user_tag creates tags on snapshots - by default each snapshot is tagged with volume_id and current_date timestamp
user_tags=false
#sets the Purge Snapshot feature to false - if purge_snapshots=true then snapshots will be purged
purge_snapshots=true
#handles options processing

while getopts :l:s:c:r:v:t:k:pnhu opt
    do
        case $opt in
            l) label="$OPTARG";;
            s) selection_method="$OPTARG";;
            c) cron_primer="$OPTARG";;
            r) region="$OPTARG";;
            v) volumeid="$OPTARG";;
            t) tag="$OPTARG";;
            k) purge_after_input="$OPTARG";;
            n) name_tag_create=true;;
            h) hostname_tag_create=true;;
            p) purge_snapshots=true;;
            u) user_tags=true;;
            *) echo "Error with Options Input. Cause of failure is most likely that an unsupported parameter was passed or a parameter was passed without a corresponding option." 1>&2 ; exit 64;;
        esac
    done

#sources "cron_primer" file for running under cron or other restricted environments - this file should contain the variables and environment configuration required for ec2-automate-backup to run correctly
if [[ -n $cron_primer ]]; then
  if [[ -f $cron_primer ]]; then
    source $cron_primer
  else
    echo "Cron Primer File \"$cron_primer\" Could Not Be Found." 1>&2 ; exit 70
  fi
fi

#if region is not set then:
if [[ -z $region ]]; then
  #if the environment variable $EC2_REGION is not set set to us-east-1
  if [[ -z $EC2_REGION ]]; then
    region="us-east-1"
  else
    region=$EC2_REGION
  fi
fi

#calls prerequisitecheck function to ensure that all executables required for script execution are available
prerequisite_check

#sets date variable
current_date=$(date -u +%s)

#sets the PurgeAfterFE tag to the number of seconds that a snapshot should be retained
if [[ -n $purge_after_input ]]; then
  #if the date_binary is not set, call the get_date_binary function
  if [[ -z $date_binary ]]; then
    get_date_binary
  fi
  purge_after_date_fe=$(get_purge_after_date_fe)
  echo "Snapshots taken by $app_name will be eligible for purging after the following date (the purge after date given in seconds from epoch): $purge_after_date_fe."
fi

#get_EBS_List gets a list of EBS instances for which a snapshot is desired. The list of EBS instances depends upon the selection_method that is provided by user input
get_EBS_List

#the loop below is called once for each volume in $ebs_backup_list - the currently selected EBS volume is passed in as "ebs_selected"
for ebs_selected in $ebs_backup_list; do
  ec2_snapshot_description="${label}"

  ec2_snapshot_resource_id=$(aws ec2 create-snapshot --region $region --description $ec2_snapshot_description --volume-id $ebs_selected --output text --query SnapshotId 2>&1)
  if [[ $? != 0 ]]; then
    echo -e "An error occurred when running ec2-create-snapshot. The error returned is below:\n$ec2_create_snapshot_result" 1>&2 ; exit 70
  fi  
  create_EBS_Snapshot_Tags
done

#if purge_snapshots is true, then run purge_EBS_Snapshots function
if $purge_snapshots; then
  echo "Snapshot Purging is Starting Now."
  purge_EBS_Snapshots
fi
amazon-ec2
  • 1 个回答
  • 483 Views
Martin Hope
richelliot
Asked: 2015-01-07 08:23:38 +0800 CST

PHP网站停止了一个小时,然后运行良好....如何调试?

  • -2

我有一个使用 $_SESSION 变量的 PHP 网站。它在 Apache、Mysql 和 Ubuntu 14.04 上运行在一个资源丰富的服务器上 (Amazon EC2 - M3.X-large)

由于某种未知的原因,该网站几乎每隔一段时间就会停止运行,我不知道为什么。发生这种情况时,很少有人访问该网站,并且服务器负载非常低。重新启动 Apache 和 MySQL 没有任何效果,但是,大约一个小时后,网站速度恢复正常。重新启动我的整个服务器也可以暂时解决问题,但几天后问题再次出现。

我的问题是 - 什么可能导致这个问题,我可以做些什么来调试/修复它?就像我说的 - 问题发生时流量非常低,所以我不认为 apache / php 需要更多资源。我认为问题更深层次。保存的会话数据量是否会导致问题?

提前致谢。

apache-2.2
  • 1 个回答
  • 73 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve