首页 \ 问答 \ Crontab CD到目录(Crontab CD to Directory)

Crontab CD到目录(Crontab CD to Directory)

我的所有cronjob脚本都从特定目录运行。 我可以在crontab文件的顶部添加cd /FOLDER/PATH ,并期望从该目录运行所有脚本吗?

目前我所有的crontab功能都是这样的(忽略缺少特定的运行频率)

* * * * * cd /FOLDER/PATH && python3 File.py
* * * * * cd /FOLDER/PATH && python3 File2.py
* * * * * cd /FOLDER/PATH && python3 File3.py

我宁愿这样

cd /FOLDER/PATH
* * * * * python3 File.py
* * * * * python3 File2.py
* * * * * python3 File3.py

All of my cronjob scripts run from a specific directory. Can I add cd /FOLDER/PATH at the top of the crontab file and expect all scripts to be run from that directory?

Currently all my crontab functions are like this (ignore lack of specific run frequencies)

* * * * * cd /FOLDER/PATH && python3 File.py
* * * * * cd /FOLDER/PATH && python3 File2.py
* * * * * cd /FOLDER/PATH && python3 File3.py

I would rather it be like

cd /FOLDER/PATH
* * * * * python3 File.py
* * * * * python3 File2.py
* * * * * python3 File3.py

原文:https://stackoverflow.com/questions/36781488
更新时间:2019-12-07 10:55

相关问答

更多

如何显示完整尺寸(How to show full size)

听起来你需要增加日期标签对压缩的抵抗力。 默认情况下,标签的抗压缩优先级为750.您只需要为日期标签将此优先级提高1。 这将导致名称标签的内容被压缩。 [_labelDate setContentCompressionResistancePriority:751 forAxis:UILayoutConstraintAxisHorizontal]; Sounds like you need to increase the date label's resistance to compressio

脚本拼图

最新问答

更多
  • NumPy标量,广播和__iadd__方法(NumPy scalars, broadcasting and the __iadd__ method)
  • 快速排序算法输出错误(Getting wrong output for quicksort algorithm)
  • Rails管理员:没有Rails 4应用程序的编辑,显示或删除按钮(Rails Admin: No edit, show, or delete buttons for Rails 4 app)
  • 部分刷新问题触发两次(Issue with partial refresh triggered twice)
  • jsPlumb draggable element javascript函数(jsPlumb draggable element javascript function)
  • MVC4:ViewModel(带有radiobuttonlist)在HttpPost之后为空(MVC4: ViewModel (with radiobuttonlist) is empty after HttpPost)
  • 如何在同一帐户上设置“Dev repo”(在prod和团队之间)(How to set up a “Dev repo” (between the prod and the team) on the same account)
  • 如何在tcl中将eth0配置为发送方udp端口(how to configure eth0 as a sender udp port in tcl)
  • EF6.1 beta 1如何获得Tooling Consolidation功能?(EF6.1 beta 1 how to get the Tooling Consolidation feature?)
  • 适用于Windows和PHP 5.5的Phalcon(Phalcon for Windows and PHP 5.5)
  • 有没有办法忽略hg责任中的提交?(Is there a way to ignore a commit in hg blame?)
  • Desire2通过API学习访问学期的权限(Desire2Learn Permissions to Access Semesters Via API)
  • 从aspx将服务器的文件复制到另一台服务器(Copy a file of a server to another server from aspx)
  • 使用YSlow / Web Developer扩展程序确定页面大小(Figuring out page size with YSlow / Web Developer extension)
  • Select语句将字符串中的前7个字符与其他表中的其他7个字符进行比较(Select statement which compares first 7 chars in a string with other 7 chars in other table)
  • 检测对注册表的更改,防止更改等(Detect changes to registry, prevent changes, etc)
  • 用户的鼠标/键盘运动分析是否有特殊名称?(Does the analysis of mouse/keyboard motions of a user have a special name?)
  • 获取Rails中资源的路由列表(Get list of routes for a resource in Rails)
  • 用函数值除以数字(Divide a function value by a number)
  • 熊猫Python:如何从今天开始创建失效列?(Pandas Python: How to create lapse since today column?)
  • GDK Bug报告(GDK Bug Reports)
  • 困惑于在python中循环遍历列表(confused about looping through lists in python)
  • 'less'由'which'输出指定的文件('less' the file specified by the output of 'which')
  • 如何在ASP.NET中优化AJAX(How to optimize AJAX in ASP.NET)
  • 在文本文件中转换纪元时间(Convert epoch times in text file)
  • 表细胞伸展(Table cell stretching)
  • GridView控件(GridView Control)
  • 从构建定义文件控制pdb文件输出(Control pdb file output from build defintion file)
  • *将方法传递给类(*Passing a Method into a Class)
  • 如何在HttpReceiveHttpRequest()中使用HTTPS?(How to use HTTPS with HttpReceiveHttpRequest()?)