How to Run a Cron Job Inside a Docker Container

Поділитися
Вставка
  • Опубліковано 12 січ 2025

КОМЕНТАРІ • 5

  • @seanys
    @seanys 15 днів тому

    Thanks. This helped me finally get my cron'ed Python scripts off the OS and into a container. Only took me 3 years since I first planned it be that way.

  • @RenukeshDeshpande
    @RenukeshDeshpande 7 місяців тому +2

    Not working at my end , the log file is unchanged
    when i enter into the container i see like this
    # cd var
    # cd log
    # pwd
    /var/log
    # ld -l
    /bin/sh: 4: ld: not found
    # ls -l
    total 260
    lrwxrwxrwx 1 root root 39 Jun 17 07:56 README -> ../../usr/share/doc/systemd/README.logs
    -rw-r--r-- 1 root root 4508 May 30 02:06 alternatives.log
    drwxr-xr-x 1 root root 4096 Jun 17 07:55 apt
    -rw-r--r-- 1 root root 61229 May 30 02:03 bootstrap.log
    -rw-rw---- 1 root utmp 0 May 30 02:03 btmp
    drwxr-xr-x 5 root root 4096 Jun 17 07:51 cron.log
    -rw-r--r-- 1 root root 29 Jun 17 11:07 'cron.log'$'
    '
    -rw-r--r-- 1 root root 165221 Jun 17 07:56 dpkg.log
    -rw-r--r-- 1 root root 0 May 30 02:03 faillog
    drwxr-sr-x+ 2 root systemd-journal 4096 Jun 17 07:56 journal
    -rw-rw-r-- 1 root utmp 0 May 30 02:03 lastlog
    drwx------ 2 root root 4096 Jun 17 07:56 private
    -rw-rw-r-- 1 root utmp 0 May 30 02:03 wtmp

    • @WittCode
      @WittCode  5 місяців тому +1

      I would have to see the entire setup but if it is log file based it is most likely the volume mapping. Make sure you are copying a log file into the container!

  • @arete_
    @arete_ 5 місяців тому

    On Windows I had to do:
    docker run -d -v C:\Users\admin\Desktop:/var/log/ cron-i

    • @WittCode
      @WittCode  5 місяців тому +1

      That shouldn't be windows specific! The path is windows based but you're changing your volume location to your Desktop and running in the background with -d. So essentially you're copying your Desktop contents into the /var/log folder in the container