首页 \ 问答 \ Bash cron作业不会像在命令行上那样执行(Bash cron job doesn't execute like it does on command line)

Bash cron作业不会像在命令行上那样执行(Bash cron job doesn't execute like it does on command line)

我编写了一个执行python脚本的bash脚本,将文件写入目录,然后将该文件发送到Amazon S3。 当我从命令行执行脚本时它完全执行,但是当我用cron运行它时,文件写入目录,但永远不会被发送到S3。 我必须对cron做错事。

这是bash脚本:

#!/bin/bash

#python script that exports file to home directory
python some_script.py

#export file created by python to S3
s3cmd put /home/bitnami/myfile.csv s3://location/to/put/file/myfile.csv

就像我之前说过的那样,使用./bash_script.sh手动执行工作正常。 当我设置cron作业时,文件会写入目录,但永远不会被发送到S3。

我的cron工作是:

18 * * * * /home/bitnami/bash_script.sh

我错误地使用了cron吗? 请帮忙。


I've written a bash script that executes a python script to write a file to a directory, then sends that file to Amazon S3. When I execute the script from the command line it executes perfectly, but when I run it with cron, the file writes to the directory, but never gets sent to S3. I must be doing something wrong with cron.

Here is the bash script:

#!/bin/bash

#python script that exports file to home directory
python some_script.py

#export file created by python to S3
s3cmd put /home/bitnami/myfile.csv s3://location/to/put/file/myfile.csv

Like I said before, manually executing works fine using ./bash_script.sh. When I set up the cron job, the file writes to the directory, but never gets sent to S3.

my cron job is:

18 * * * * /home/bitnami/bash_script.sh

Am I using cron incorrectly? Please help.


原文:https://stackoverflow.com/questions/29086371
更新时间:2020-11-25 17:11

最满意答案

假设你还没有推动任何事情,你的历史看起来像这样

A -- B -- C -- D -- E
^                   ^
|                   |
origin/master       master

您可以执行以下操作:

git branch feature
git reset origin/master

得到这个:

A -- B -- C -- D -- E
^                   ^
|                   |
|                   feature
origin/master,master

Assuming you have't pushed anything yet and your history looks something like

A -- B -- C -- D -- E
^                   ^
|                   |
origin/master       master

You can just do the following:

git branch feature
git reset origin/master

to get this:

A -- B -- C -- D -- E
^                   ^
|                   |
|                   feature
origin/master,master

相关问答

更多
  • 假设你还没有推动任何事情,你的历史看起来像这样 A -- B -- C -- D -- E ^ ^ | | origin/master master 您可以执行以下操作: git branch feature git reset origin/master 得到这个: A -- B -- C -- D -- E ^ ^ | | | ...
  • 从公告Git 1.7.10 (2012年4月): git clone学习--single-branch选项将克隆限制到单个分支(惊喜!); 不指向分支的历史记录的标签不会被获取。 Git实际上只允许克隆一个分支,例如: git clone -b mybranch --single-branch git://sub.domain.com/repo.git 注意 : 您还可以添加另一个分支或“撤消”此操作。 From the announcement Git 1.7.10 (April 2012): git ...
  • git init git remote add -t refspec remotename host:/dir.git git fetch 但是如果我记得正确,默认情况下,克隆从远程而不是当前工作分支获取所有分支。 Please see also the other answer which many people prefer. You may also want to make sure you understand the difference. And the difference is: by ...
  • git branch默认只显示本地分支; 使用git branch -r查看远程分支或git branch -a查看全部。 git clone仅创建一个本地分支,默认情况下为master ,它跟踪(同样默认情况下)远程存储库上的master分支。 git branch only shows local branches by default; use git branch -r to see remote branches or git branch -a to see all. git clone onl ...
  • 如果您在以下方面遇到错误: git clone git@bitbucket.org:name/name.git -b mv_LookbookAddition --single-branch 这意味着您需要1.7.10+(2012年6月),对于Linux,使用ppa或git-scm.com/download/mac for Mac。 但是,您将获得分支的完整历史记录(如果该分支是从master创建的,则将从master分支获得所有提交,直到分支开始,再加上分支提交) 您可以尝试合并--depth选项以仅从分 ...
  • 默认情况下,在克隆操作之后,您将位于已在git配置中标记为默认分支的分支上。 假设您正在使用GitHub,可以通过“设置”页面进行配置: 一旦克隆了存储库,就可以执行git checkout 进入您感兴趣的分支。 或者,您可以更改默认分支(如果这对您和您的团队有意义)。 By default, following the clone operation, you will be on the branch that has been marked as the default bra ...
  • 您没有克隆分支,克隆整个项目: $ git clone git://github.com/openstack/neutron Cloning into 'neutron'... remote: Counting objects: 105856, done. remote: Total 105856 (delta 0), reused 0 (delta 0) Receiving objects: 100% (105856/105856), 44.17 MiB | 1.06 MiB/s, done. Resol ...
  • 为精致的问题发布另一个答案。 如果这将更难以合作,以什么方式? 这样做有什么陷阱? 我需要采取哪些步骤将这些更改合并到主服务器中? 就像我在第一个答案中提到的那样,每个克隆都是一个单独的存储库,但是指向相同的Git URI,即//[...]/project_1.git ,即仅通过remote连接到彼此。 使用上图解释, 要通过[local-Bug Fixes]的发展更新[local-Main],只有两种方法: 通过命令行: push [local-Bug Fixes] git push origin bug ...

相关文章

更多

最新问答

更多
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)
  • 是否可以嵌套hazelcast IMaps?(Is it possible to nest hazelcast IMaps? And whick side effects can I expect? Is it a good Idea anyway?)
  • UIViewAnimationOptionRepeat在两个动画之间暂停(UIViewAnimationOptionRepeat pausing in between two animations)
  • 在x-kendo-template中使用Razor查询(Using Razor query within x-kendo-template)
  • 在BeautifulSoup中替换文本而不转义(Replace text without escaping in BeautifulSoup)
  • 如何在存根或模拟不存在的方法时配置Rspec以引发错误?(How can I configure Rspec to raise error when stubbing or mocking non-existing methods?)
  • asp用javascript(asp with javascript)
  • “%()s”在sql查询中的含义是什么?(What does “%()s” means in sql query?)
  • 如何为其编辑的内容提供自定义UITableViewCell上下文?(How to give a custom UITableViewCell context of what it is editing?)
  • c ++十进制到二进制,然后使用操作,然后回到十进制(c++ Decimal to binary, then use operation, then back to decimal)
  • 以编程方式创建视频?(Create videos programmatically?)
  • 无法在BeautifulSoup中正确解析数据(Unable to parse data correctly in BeautifulSoup)
  • webform和mvc的区别 知乎
  • 如何使用wadl2java生成REST服务模板,其中POST / PUT方法具有参数?(How do you generate REST service template with wadl2java where POST/PUT methods have parameters?)
  • 我无法理解我的travis构建有什么问题(I am having trouble understanding what is wrong with my travis build)
  • iOS9 Scope Bar出现在Search Bar后面或旁边(iOS9 Scope Bar appears either behind or beside Search Bar)
  • 为什么开机慢上面还显示;Inetrnet,Explorer
  • 有关调用远程WCF服务的超时问题(Timeout Question about Invoking a Remote WCF Service)