npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ymlr-cron

v1.2.3-alpha.0

Published

Schedule jobs to do something base on cron pattern

Downloads

141

Readme

ymlr-cron

Schedule jobs to do something base on cron pattern

Features:

  1. Schedule jobs

Tag details

| Tags | Description | |---|---| | cron | Schedule a task with cron pattern | | cron'del | Stop a running cron job and delete it in cached | | cron'pause | Pause a running cron job | | cron'resume | Resume a pausing cron job |

cron

Schedule a task with cron pattern * * * * * * (sec) (min) (hour) (date) (month) (dayOfWeek)

  • sec execution seconds (0-23)
  • min execution minutes (0-23)
  • hour execution hours (0-23)
  • date execution date of month (1-31)
  • month execution month (1-12)
  • dayOfWeek execution day of week (0-7) - 0 or 7 is Sunday, 1 is Monday ...

Example:

Print a message

  - name: Schedule a job at 00:00:00 AM
    ymlr-cron:
      time: 0 0 0 * * *
      #times:                                   # Support multple times
      #  - 0 * * * * 1,2                        # Exec at each of minutes of MON, TUE
      #  - 0 0 * * * 3,4,5,6,0                  # Exec each of 00:00 of WED, THU, FRI, SAT, SUN
      scheduled: true
      runs:
        - name: Execute a job 1
      scheduled: false          # Start ASAP. Default true
      runOnInit:                # This will immediately fire your onTick function as soon as the requisite initialization has happened. This option is set to false by default for backwards compatibility.
      runs:
        - echo: Executed a job at ${ $parentState.cronData.execTime }  # $parentState.cronData.time: cron pattern (Date)
                                                              # $parentState.cronData.task: Task object
                                                              # $parentState.cronData.index: Task index (when use multiple times)
                                                              # $parentState.cronData.lastDate: Tells you the last execution date.
                                                              # $parentState.cronData.nextDate: Provides the next date that will trigger an onTick.

        - stop:                                               # Stop cron job, dont execute anymore

cron'del

Stop a running cron job and delete it in cached

Example:

  - name: Schedule a job                       # Create a cron job "cron01" and shedule it
    ~ymlr-cron:
      name: cron01
      time: 0 * * * * *
      scheduled: true
      runs:
        - name: Execute a job 1

  - ~runs:
      - ymlr-cron'del: cron01                # Pause and remove it in cached. After this, the cron task will be finished to keep playing the next steps

  - name: cron job has been stoped !

cron'pause

Pause a running cron job

Example:

  - name: Schedule a job                       # Create a cron job "cron01" and shedule it
    ~ymlr-cron:
      name: cron01
      time: 0 * * * * *
      scheduled: true
      runs:
        - name: Execute a job 1

  - ~runs:
      - ymlr-cron'pause: cron01                # Pause it but keep it in cached to resume later
      - sleep: 10s
      - ymlr-cron'resume: cron01               # Resume it after 10s

cron'resume

Resume a pausing cron job

Example:

  - name: Schedule a job                       # Create a cron job "cron01" but not run yet
    ~ymlr-cron:
      name: cron01
      time: 0 * * * * *
      scheduled: false
      runs:
        - name: Execute a job 1

  - ~runs:
      - sleep: 5s                               # sleep 5s before start "cron01"
      - ymlr-cron'resume: cron01

Have fun :)