Create cronjob for given time from HTML-Form

296
March 14, 2017, at 8:11 PM

I have a HTML-Form where the user inputs a time (HH:mm).

What I want to do is that this time is used to create a cronjob on the system that deletes a file. The file is always the same. The only thing that can change is the given time from the user.

I am using JavaScript (NodeJS Server), no PHP.

Answer 1

As per my comment, you can use an external NodeJS library to interact with cron, like node-cron , which will also provide some nice extra features (extended interval syntax, callbacks...).

Answer 2

You can see this question to execute commands over server with NodeJS, Execute a command line binary with Node.js

To convert the time in HH:mm to crontab in linux only split in ":" and apply to the crontab with the next format:

* * * HH mm Function....

The next time that the hour pass, your crontab will execute. Remember remove this crontab when don't it's necesary or every day at the same time, the crontab trigger the function.

Regards

READ ALSO
TypeError: semrush.backlinks_refdomains is not a function

TypeError: semrush.backlinks_refdomains is not a function

Guys when i was trying to get data from SEMRUSH API https://wwwsemrush

461
Clearing Node.js' cache when loading non-js files e.g. graphql language defenitions

Clearing Node.js' cache when loading non-js files e.g. graphql language defenitions

I want to clear Node's cache from my graphql defintions but nothing happens until I make a change to the file where the require('mygraphql') statement is

406
Simple app admin UI in Heroku or Firebase?

Simple app admin UI in Heroku or Firebase?

I would appreciate if someone could point me to the more simple direction between Firebase and Heroku

368
Video Chat app on Heroku using Peer js and Node js

Video Chat app on Heroku using Peer js and Node js

I'm following this tutorial on https://wwwsitepoint

366