暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Python实现获取【昨天】【今天】【明天】日期和shell交互

zayki 2023-12-25
118
  • 昨天

    from datetime import date, timedelta
    
    yesterday = (date.today() + timedelta(days=-1)).strftime("%Y-%m-%d")
    print(yesterday)
    

    img

    今天

    img

    明天

    from datetime import date, timedelta
    
    tomorrow = (date.today() + timedelta(days= 1)).strftime("%Y-%m-%d")
    print(tomorrow)
    

    img

[itadmin@dlidcimageapp1 ~]$ pstree |grep python
|-bash—python—bash—find
|-bash—python—bash
[itadmin@dlidcimageapp1 ~]$ ps -ef|grep find
itadmin 15989 13688 0 14:09 pts/2 00:00:00 grep find
itadmin 21185 20866 0 2021 pts/1 00:00:32 find / -name 20210909
[itadmin@dlidcimageapp1 ~]$ ps -ef|grep python
luci 5357 1 0 2021 ? 00:39:55 /usr/bin/python -Es /usr/sbin/luci serve --daemon --user luci --group luci --log-file=/var/log/luci/luci.log --pid-file=/var/run/luci/luci.pid --server-name=init --app-name=init /var/lib/luci/etc/luci.ini INITPID=5128
itadmin 16071 13688 0 14:09 pts/2 00:00:00 grep python
itadmin 20865 20864 0 2021 ? 21:33:43 python -c import pty; pty.spawn("/bin/bash")
itadmin 23920 23917 0 2021 ? 21:33:42 python -c import pty; pty.spawn("/bin/bash")
[itadmin@dlidcimageapp1 ~]$ ps -ef|grep 21185
itadmin 16421 13688 0 14:10 pts/2 00:00:00 grep 21185
itadmin 21185 20866 0 2021 pts/1 00:00:32 find / -name 20210909
[itadmin@dlidcimageapp1 ~]$ ps -ef|grep 20866
itadmin 16454 13688 0 14:10 pts/2 00:00:00 grep 20866
itadmin 20866 20865 0 2021 pts/1 00:00:00 /bin/bash
itadmin 21185 20866 0 2021 pts/1 00:00:32 find / -name 20210909
[itadmin@dlidcimageapp1 ~]$ ps -ef|grep 20865
itadmin 16482 13688 0 14:10 pts/2 00:00:00 grep 20865
itadmin 20865 20864 0 2021 ? 21:35:10 python -c import pty; pty.spawn("/bin/bash")
itadmin 20866 20865 0 2021 pts/1 00:00:00 /bin/bash

[itadmin@dlidcimageapp2 ~]$ ps -ef|grep find
itadmin 24544 23684 0 14:16 pts/6 00:00:00 grep find
itadmin 25269 5371 0 2021 ? 02:32:46 find / -name 20210909133748_temp_img_2021991631165868947.jsp
[itadmin@dlidcimageapp2 ~]$ ps -ef|grep find
itadmin 24605 23684 0 14:16 pts/6 00:00:00 grep find
[itadmin@dlidcimageapp2 ~]$ ps -ef|grep python
luci 5426 1 0 2021 ? 00:36:40 /usr/bin/python -Es /usr/sbin/luci serve --daemon --user luci --group luci --log-file=/var/log/luci/luci.log --pid-file=/var/run/luci/luci.pid --server-name=init --app-name=init /var/lib/luci/etc/luci.ini INITPID=5192
itadmin 21795 21794 0 2021 ? 00:00:00 python -c import pty; pty.spawn("/bin/bash")
itadmin 21883 1 99 2021 ? 222-20:28:42 python -c import pty; pty.spawn("/bin/bash")
itadmin 24623 23684 0 14:16 pts/6 00:00:00 grep python
itadmin 24982 24981 0 2021 ? 00:00:00 python -c import pty; pty.spawn("/bin/bash")
[itadmin@dlidcimageapp2 ~]$ ps -ef|grep python
luci 5426 1 0 2021 ? 00:36:40 /usr/bin/python -Es /usr/sbin/luci serve --daemon --user luci --group luci --log-file=/var/log/luci/luci.log --pid-file=/var/run/luci/luci.pid --server-name=init --app-name=init /var/lib/luci/etc/luci.ini INITPID=5192
itadmin 21795 21794 0 2021 ? 00:00:00 python -c import pty; pty.spawn("/bin/bash")
itadmin 21883 1 99 2021 ? 222-20:29:21 python -c import pty; pty.spawn("/bin/bash")
itadmin 24829 23684 0 14:17 pts/6 00:00:00 grep python
itadmin 24982 24981 0 2021 ? 00:00:00 python -c import pty; pty.spawn("/bin/bash")


「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论