Skip to content

Commit 970eaed

Browse files
committed
add cron job for onrender
Signed-off-by: Amit Amrutiya <amitamrutiya2210@gmail.com>
1 parent d392198 commit 970eaed

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

backend/cron.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import cron from "cron";
2+
import https from "https";
3+
4+
const URL = "https://expense-tracker-pur1.onrender.com";
5+
6+
const job = new cron.CronJob("*/14 * * * *", function () {
7+
https
8+
.get(URL, (res) => {
9+
if (res.statusCode === 200) {
10+
console.log("GET request sent successfully");
11+
} else {
12+
console.log("GET request failed", res.statusCode);
13+
}
14+
})
15+
.on("error", (e) => {
16+
console.error("Error while sending request", e);
17+
});
18+
});
19+
20+
export default job;

0 commit comments

Comments
 (0)