Results 1 to 7 of 7
  1. #1

    How to run command with cd using cron?

    I use the new relic to monitor my servers and MySQL. I already configured newrelic_mysql_plugin-1.0.7.jar file location and copied newrelic-mysql-plugin.debian and newrelic-mysql-plugin.rh these two files to /etc/int.d folder and reboot Apache and VPS. However its MySQL plugin fails to send data after 20-30 minutes left.

    My VPS MySQL plugin installed this folder "/root/support/newrelic_mysql_plugin-1.0.7". To fix this issue every time I have to run following command line to re-start that plugin.

    cd /root/support/newrelic_mysql_plugin-1.0.7
    java -jar newrelic_mysql_plugin-1.0.7.jar

    Therefore I'm considering running it as a cron job. As far as I know, I have to use following type crontab job command (planned to run every 20 minutes).

    20 * * * * root <command>

    New relic newrelic_mysql_plugin-1.0.7.jar file located in following directory. So how do I navigate to this directory and execute command using cron.


    Last edited by Slim Shaddy; 10-18-2013 at 10:24 AM.

  2. #2
    You need to create a script that will have above code and using cron run that script at regulat interval which will do your things.

  3. #3
    Join Date
    Jun 2011
    What's wrong with doing this?

    java -jar /root/support/newrelic_mysql_plugin-1.0.7/newrelic_mysql_plugin-1.0.7.jar

    Or better yet : find out why it's failing in the first place

  4. #4
    Join Date
    Dec 2005
    Start it normally first from console and check errors or better consider redirecting errors to some file for later investigation.
    Marcin Krupinski
    Fast,reliable VPS and Dedicated Servers in Europe (Germany / Netherlands)
    Red Hat Certified Engineer(RHCE)

  5. #5
    I have fixed it by using this command.

    20 * * * * cd /root/support/newrelic_mysql_plugin-1.0.7; java -jar newrelic_mysql_plugin-1.0.7.jar

  6. #6
    Join Date
    Sep 2008
    You should really fix the root of the problem instead of restarting it every 20 minutes.
    TaleHost | Quality Web Hosting | US / Asia
    LiteSpeed | Pure SSD | Softacolous | Automated Backups

  7. #7
    Join Date
    Jul 2008
    Seminole, OK
    Quote Originally Posted by Slim Shaddy View Post
    I have fixed it by using this command.

    20 * * * * cd /root/support/newrelic_mysql_plugin-1.0.7; java -jar newrelic_mysql_plugin-1.0.7.jar
    This cron is running the 20th min of every hour, meaning running hourly. you need to change it like this

    */20 * * * * cd /root/support/newrelic_mysql_plugin-1.0.7; java -jar newrelic_mysql_plugin-1.0.7.jar
    Notice the "*/20" on the first time setting, that will run every 20mins or 3 times an hour.
    Inode Hosting - Reliable Web Hosting for the right price.
    Shared & Reseller hosting featuring the industry leading cpanel
    99.9% Uptime Guarantee ,30 Day Money Back Guarantee ,24/7 Support
    Established since 2011

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts