-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5511331
commit c0f6acb
Showing
3 changed files
with
79 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import cron from "cron"; | ||
import https from "https"; | ||
|
||
const URL = "https://threads-clone-9if3.onrender.com"; | ||
|
||
const job = new cron.CronJob("*/14 * * * *", function () { | ||
https | ||
.get(URL, (res) => { | ||
if (res.statusCode === 200) { | ||
console.log("GET request sent successfully"); | ||
} else { | ||
console.log("GET request failed", res.statusCode); | ||
} | ||
}) | ||
.on("error", (e) => { | ||
console.error("Error while sending request", e); | ||
}); | ||
}); | ||
|
||
export default job; | ||
|
||
// CRON JOB EXPLANATION: | ||
// Cron jobs are scheduled tasks that run periodically at fixed intervals or specific times | ||
// send 1 GET request for every 14 minutes | ||
|
||
// Schedule: | ||
// You define a schedule using a cron expression, which consists of five fields representing: | ||
|
||
//! MINUTE, HOUR, DAY OF THE MONTH, MONTH, DAY OF THE WEEK | ||
|
||
//? EXAMPLES && EXPLANATION: | ||
//* 14 * * * * - Every 14 minutes | ||
//* 0 0 * * 0 - At midnight on every Sunday | ||
//* 30 3 15 * * - At 3:30 AM, on the 15th of every month | ||
//* 0 0 1 1 * - At midnight, on January 1st | ||
//* 0 * * * * - Every hour |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters