Find the answer to your Linux question:
Page 1 of 3 1 2 3 LastLast
Results 1 to 10 of 23
I'm having a problem starting up some programs via cron. (I changed the name just for anonymity). works fine when I run it manually from /home/mystuff/programs/bin ./psProgram ../conf/1.psProgram in the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2012
    Posts
    16

    Having problem with cron jobs


    I'm having a problem starting up some programs via cron. (I changed the name just for anonymity).

    works fine when I run it manually from /home/mystuff/programs/bin

    ./psProgram ../conf/1.psProgram

    in the cron job I enter this, but it's not working.

    00 04 * * * /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf

    I thought maybe its an issue with the PATH? I dont know.

    (ps I'm relatively new to linux) thanks for your help.

  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    How are you setting up the cron job? Also, in your local example, you run the script with the psProgram command. So, you either need to add that to the job, using the full path, or you need to alter the cronjob's PATH variable to include /home/mystuff/programs/bin.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  3. #3
    Just Joined!
    Join Date
    Apr 2012
    Posts
    16
    well I first just tried to setup a regular cronjob using crontab -e when that didnt work, I tried to set up a script that runs my program.

    in that script I have this..

    #!/bin/bash

    #setup cron environment
    export LD_LIBRARY_PATH=/home/mystuff/programs/lib

    /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf

  4. $spacer_open
    $spacer_close
  5. #4
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    Post here the path of your user cron job set up with the cronjob command and the contents of the cron file it created inside a code block. Here is an example of the system cron job /etc/cron.d/0hourly:
    Code:
    SHELL=/bin/bash
    PATH=/sbin:/bin:/usr/sbin:/usr/bin
    MAILTO=root
    HOME=/
    01 * * * * root run-parts /etc/cron.hourly
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  6. #5
    Just Joined!
    Join Date
    Apr 2012
    Posts
    16
    where do I find the cron file it created?

  7. #6
    Just Joined!
    Join Date
    Apr 2012
    Posts
    16
    this is the what I had in crontab -l

    SHELL=bin/bash

    00 04 * * * /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf

    that did not work so I created StartProgram.sh

    vi StartProgram.sh I had this...

    #!/bin/bash

    #setup cron environment
    export LD_LIBRARY_PATH=/home/mystuff/programs/lib

    /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf




    I know this might not be what you're asking, but I wanted to just be clear where I'm at now.

  8. #7
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    I want the cron file, not the script. When you run "crontab -e" it brings up your cron file in an editor (probably vi). In vi you can see the file path + name with the input (in command mode) ":f"
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  9. #8
    Just Joined!
    Join Date
    Apr 2012
    Posts
    16
    this is all that is in crontab -e (in vi)

    SHELL=bin/bash

    00 04 * * * /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf

  10. #9
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    Oops. Sorry, but "crontab -e" edits a temporary file which goes into your file when you exit the editor. The user crontabs are stored in /var/spool/cron (only accessible with sudo or as root). IE, your cron file would bin the file /var/spool/cron/username. That's the file I want.
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

  11. #10
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,748
    Quote Originally Posted by jlew24asu View Post
    this is all that is in crontab -e (in vi)

    SHELL=bin/bash

    00 04 * * * /home/mystuff/programs/bin/psProgram /home/mystuff/program/conf/1.psProgram.conf
    If the program has output, you probably want to redirect it to a known file, otherwise how do you know that it ran?
    Also, I presume that the psProgram file is executable? Also, note the SHELL environment variable - the path is missing a leading slash. It should be "SHELL=/bin/bash". That is probably why it isn't running - it is looking for a non-existent bash executable...
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Page 1 of 3 1 2 3 LastLast

Posting Permissions

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