Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
163 views
in Technique[技术] by (71.8m points)

python - 在特定时间打开文件。 C ++ / Python(Open file at specific time. C++/python)

I have .sh file on my macOS Catalina.

(我的macOS Catalina上有.sh文件。)

I would like to open it at eg 1 PM (I need accuracy).

(我想在下午1点打开它(我需要准确)。)

So, I have already tried crontab, but something goes wrong, and I can't do it.

(因此,我已经尝试过crontab,但是出了点问题,但是我做不到。)

So, Is it possible to make a program on C++ or Python to open a file at specific time?

(那么,是否可以在特定时间使用C ++或Python编写程序来打开文件?)

I have some skills in C++, but as I know there are no libs with reading current time, maybe I wrong?

(我有一些C ++技能,但是据我所知,没有库可以读取当前时间,也许我错了吗?)

I haven't any knowledge in Python, but is it possible anywhere?

(我对Python没有任何了解,但是在任何地方都可以吗?)

Thank you!

(谢谢!)

UPD:

(UPD:)

int main() {
    struct tm *tim;
    time_t tt = time(NULL);
    tim = localtime(&tt);
    while(!(tim->tm_hour==** && tim->tm_min == ** && tim->tm_sec == **)) {
        tt = time(NULL);
        tim = localtime(&tt);
    }
    system("...");
}

Looks like a bad idea, but it works...

(看来是个坏主意,但确实可行...)

  ask by Sergey translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...