Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GetTasks to Readme and move Validate to correct location #346

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
42 changes: 31 additions & 11 deletions README.md
Expand Up @@ -152,6 +152,37 @@ Arguments:
timezone: "America/Sao_Paulo"
});
```
### GetTasks

Gets the currently scheduled tasks.

**Example**:

```js
var cron = require('node-cron');

cron.schedule('* * * * *', () => {
console.log('Job 1');
});

cron.schedule('* * * * *', () => {
console.log('Job 2');
});

var tasks = cron.getTasks() // returns an array of tasks (type ScheduledTask)
tasks.foreach((job) => job.stop()) // stops all the scheduled jobs
```

### Validate

Validate that the given string is a valid cron expression.

```javascript
var cron = require('node-cron');

var valid = cron.validate('59 * * * *');
var invalid = cron.validate('60 * * * *');
```

## ScheduledTask methods

Expand Down Expand Up @@ -185,17 +216,6 @@ var task = cron.schedule('* * * * *', () => {
task.stop();
```

### Validate

Validate that the given string is a valid cron expression.

```javascript
var cron = require('node-cron');

var valid = cron.validate('59 * * * *');
var invalid = cron.validate('60 * * * *');
```

## Issues

Feel free to submit issues and enhancement requests [here](https://github.com/merencia/node-cron/issues).
Expand Down