Code Monkey home page Code Monkey logo

Comments (7)

nickjj avatar nickjj commented on June 12, 2024

Hi,

The cron job is written out to disk at a specific path instead of being accessible with crontab -l.

Check out /etc/cron.d/ on your server. You should see the cron job(s) there.

from ansible-docker.

ggregoire avatar ggregoire commented on June 12, 2024

Indeed it's there, thanks!

from ansible-docker.

nickjj avatar nickjj commented on June 12, 2024

No problem. The reason for that stemmed from this issue: #35

from ansible-docker.

uchris13 avatar uchris13 commented on June 12, 2024

The cron job is written out to disk at a specific path instead of being accessible with crontab -l.

Iยดd love to understand this. why to write it directly instead of doing it via Crontab? how do you manage it? what is the logic behind all this?

from ansible-docker.

nickjj avatar nickjj commented on June 12, 2024

It's more straight forward to be able to see a list of cron jobs on your system by going to a centralized place on your file system (/etc/cron.d) than wondering which cron jobs exist in each user's crontab -l. You can still run cron jobs as a non-root user with the /etc/cron.d approach since one of the arguments of the cron job is picking which user it runs as.

From an automation standpoint it's also easier to only have to think about adding and removing files in a directory instead of parsing a crontab file from 1 or more user accounts.

from ansible-docker.

uchris13 avatar uchris13 commented on June 12, 2024

So if i understood correctly by just dropping files into /etc.d/daily, weekly, monthly scripts will be executed. How do you specify the user and the time?

I'm still a bit confused

from ansible-docker.

nickjj avatar nickjj commented on June 12, 2024

Yes, they just need to exist in any of those directories and cron picks it up automatically. You don't need to restart anything.

My role does this by default:

docker__cron_jobs_prune_flags: "af"
docker__cron_jobs_prune_schedule: ["0", "0", "*", "*", "0"]
docker__cron_jobs:
  - name: "Docker disk clean up"
    job: "docker system prune -{{ docker__cron_jobs_prune_flags }} > /dev/null 2>&1"
    schedule: "{{ docker__cron_jobs_prune_schedule }}"
    cron_file: "docker-disk-clean-up"
    user: "{{ (docker__users | first) | d('root') }}"

You can override those variables as needed if you want to change things.

By default it runs the cron job every Sunday at midnight, that's what ["0", "0", "*", "*", "0"] is, you can verify it here: https://crontab.guru/#0_0_*_*_0

from ansible-docker.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.