Last active
January 30, 2019 02:02
-
-
Save harrisonmalone/5fc1b01f5af378ff9c593e58b5ec9de0 to your computer and use it in GitHub Desktop.
cronjobs work with ruby and js
This file contains hidden or 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
def hello | |
# File.open(Random.rand.to_s + '.txt', "w+") { |f| f.write("write your stuff here") } | |
open('hello.txt', 'a') { |f| f.puts "Hello, world!" } | |
end | |
hello | |
# same process to run the cronjob as in test.js | |
# use which ruby to find where ruby is installed |
This file contains hidden or 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
var fs = require('fs'); | |
fs.writeFile(Math.random() + '.txt', "Hey there!", function(err) { | |
if(err) { | |
return console.log(err); | |
} | |
console.log("The file was saved!"); | |
}); | |
// cronjob | |
// */1 * * * * cd ~/Desktop/public && /usr/local/bin/node test.js | |
// runs every minute with */1, need to cd into that directory as all cronjobs run from home by default, then node needed the full path to work correctly as well, then run the file as normal |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment