Skip to content

Instantly share code, notes, and snippets.

@chenzixin
Last active December 28, 2015 20:09

Revisions

  1. chenzixin revised this gist Nov 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion delete-expired-file.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    ### Delete Expired File
    ## Delete Expired File

    Programed by Bingal, which will delete the files in current directory created 30 days ago.:

  2. chenzixin revised this gist Nov 20, 2013. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion delete-expired-file.md
    Original file line number Diff line number Diff line change
    @@ -6,7 +6,6 @@ Programed by Bingal, which will delete the files in current directory created 30
    #!/usr/bin/python
    # encoding: utf-8


    def main():
    import os,time
    for fn in os.listdir(os.curdir):
  3. chenzixin revised this gist Nov 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion delete-expired-file.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ### Delete Expired File

    王斌编写的脚本,清理30天之前文件
    Programed by Bingal, which will delete the files in current directory created 30 days ago.

    ```python
    #!/usr/bin/python
  4. chenzixin created this gist Nov 20, 2013.
    25 changes: 25 additions & 0 deletions delete-expired-file.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,25 @@
    ### Delete Expired File

    王斌编写的脚本,清理30天之前文件:

    ```python
    #!/usr/bin/python
    # encoding: utf-8


    def main():
    import os,time
    for fn in os.listdir(os.curdir):
    fp = os.path.join(os.curdir,fn)
    if not os.path.isfile(fp):
    continue
    if fn.startswith('.') or fn == 'delete_expired_file.py':
    continue
    ctime = int((time.time()-os.stat(fp).st_ctime)*1.0/(60*60*24))
    if ctime > 30:
    os.remove(fp)
    print fn,ctime

    if __name__=="__main__":
    main()
    ```