简体   繁体   English

如何从终端Mac Os运行python代码

[英]How to run python code a the time I want, from terminal mac Os

I'm ratheк new to programming, and my question is rather simple: How to run a bunch of code at time that I want? 我是编程的新手,我的问题很简单:如何在需要的时间运行一堆代码? what I mean is simply how to write a programm or a command in Terminal on macOs (I'm using 10.7) that will run python code at 3 o'clock AM. 我的意思是简单地如何在macO上的终端(我正在使用10.7)上编写程序或命令,该程序或命令将在凌晨3点运行python代码。 If python programm lies into: 如果python programm位于:

/Users/name/Documents/prog.py

To run the programm simply from Terminal I use: 要仅从终端运行程序,请使用:

cd /Users/name/Documents/
python prog.py 
'hit Enter'

You need cron: http://en.wikipedia.org/wiki/Cron 您需要cron: http//en.wikipedia.org/wiki/Cron

Cron is the time-based job scheduler in Unix-like computer operating systems. Cron是类Unix计算机操作系统中基于时间的作业调度程序。 Cron enables users to schedule jobs (commands or shell scripts) to run periodically at certain times or dates. Cron使用户可以计划作业(命令或Shell脚本),使其在特定时间或日期定期运行。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在 Jupyter Lab (Mac) 的终端中运行 Python 代码 - How to Run a Python Code in the Terminal from Jupyter Lab (Mac) 如何在Mac OS X中从终端运行我的python脚本而无需键入完整路径? - How can I run my python script from the terminal in Mac OS X without having to type the full path? 如何在 Mac 上的终端中运行 python? - How can I run python in terminal on a mac? 我不希望每次在 zsh(Mac 终端)的 VS Code 中运行 python 代码时打印所有这些行 - I don't want all these lines printing everytime I run the python code in VS Code in zsh (Mac terminal) 通过终端(Mac OS)编译python代码 - Compiling python code via Terminal (Mac OS) VS CODE,如何在 OS 终端中运行 python? (壳牌或 CMD) - VS CODE, how run python in OS terminal ? (Shell or CMD) 如何从终端运行python代码? - How can i run my python code from the terminal? 在Mac OS X中运行没有终端或停靠项的python脚本和已编译的c代码 - Run a python script and a compiled c code without terminal or dock item in Mac OS X 如何使用 subprocess 和 os 模块在终端(mac os)中运行命令? - How to use subprocess and os modules to run commands in terminal (mac os)? 尝试从我使用 pip3 安装的 github 运行程序。 但是当我尝试通过 Mac OS 终端运行时,它需要“Python 3.6+” - Trying to run a program from github which I've installed using pip3. But when I try to run in through the Mac OS terminal, it require's "Python 3.6+"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM