How to run a Ruby script using rbenv with cron

I’ve found a solution to load rbenv. Either with a loader importing rbenv to the PATH : */1 * * * * /bin/bash -c ‘. $HOME/.rbenv/loader.sh ; cd /data/app/; ruby -v’ The ‘.’ before ‘$HOME/.rbenv/loader.sh’ is important, it runs the script in the current shell Or without loader, which is better : */1 * * … Read more

Why crontab uses OR when both day of month and day of week specified?

Going back a step further from Vixie cron, the “wday OR mday” logic was present in System V cron, but not System III or anything earlier. Before Paul Vixie wrote his cron replacement, BSD cron was like the SysIII-and-earlier cron. All 5 fields were ANDed. The post-4.4 BSDs adopted Vixie cron, making themselves more SysV-like. … Read more

Spring Boot : Getting @Scheduled cron value from database

you can add a bean to get cron value from database in the SpringBootApplication main class or in any of the configuration class. Example code is below: @Autowired private CronRepository cronRepo; @Bean public int getCronValue() { return cronRepo.findOne(“cron”).getCronValue(); } you should create a table and provide suitable values in the database. After that you can … Read more

Crontab – simple echo not running

May be it is, cron jobs will run in their own shell. So you can’t expect to see asdf on your console. What you should try is * * * * * echo asdf > somefile_in_your_home_directory_with_complete_path.log Next check the file by doing a tail: tail -f somefile_in_your_home_directory_with_complete_path.log And if it’s not, check if the cron … Read more

How to run an X program from outside the X session (e.g. from the console or SSH) [closed]

The short answer is that you have to set the DISPLAY environment variable, and then the app will run. The long answer is that we’ve got Xauth, and unless you’re running as the same user on the same machine that’s probably not going to work unless you export the Xauth credential from the account running … Read more