Home Easiest Way to Execute a Node Script

# Easiest Way to Execute a Node Script

Dakota Lynch
1#
Dakota Lynch Published in 2018-02-14 16:55:54Z
 I have an AWS-hosted MySQL database with 900+ records. I've developed a Node script that queries the database for new records, generates MP3 files for each one, uploads those files to S3 storage, and inserts the links into my database. Right now, I'm having to execute that script manually via command prompt (npm). The script only needs to be run occasionally, so running it manually isn't a problem. But I'm sure there's an easier way than command prompt. Is there a way to automatically run the script every so often? Or perhaps run it via a desktop shortcut? I'm open to ideas on this...just looking to simplify. I am very new to Node and all things programming, so please forgive my ignorance here.
Ishan Thilina Somasiri
2#
Ishan Thilina Somasiri Reply to 2018-02-15 04:17:40Z
 In Linux, you could run as a pure Linux shell script. Use a cron job to schedule the script. Ex : #!/usr/bin/env node console.log('Hello world!');  In Windows, if you want to run manually, you could create a bat file and run the bat file to run the script. Ex : name : my_node_script.bat node c:\path\to\file\my_node_script_code.js  If you want to run the bat file periodically, you could use Task Scheduler to schedule the bat file. See this guide of you want more details on scheduling.
 You need to login account before you can post.
Processed in 0.256046 second(s) , Gzip On .