Find the answer to your Linux question:
Results 1 to 10 of 10
Hey. I have cron jobs running to update client activity every ten minutes and a dashboard update each day at 11am. When there is a SSH connection into the server ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6

    Cron not running when not logged in. Ubuntu Server


    Hey.

    I have cron jobs running to update client activity every ten minutes and a dashboard update each day at 11am.

    When there is a SSH connection into the server the scripts and cron jobs run fine.

    However when I am not logged into said server via SSH the cron jobs do not run.

    I have checked to ensure that the scripts are not in an encrypted home directory. Which they are not.

    As a workaround I have a machine logged in 24/7 to ensure data updates. But I need to solve the issue.

    Any pointers and tips on how to start resolving this issue?

    Thanks,

    Alan.

  2. #2
    Trusted Penguin Irithori's Avatar
    Join Date
    May 2009
    Location
    Munich
    Posts
    3,444
    Hi and welcome

    There is no obvious connection between cronjobs and a ssh session.
    - Do you maybe enable <whatever> ressorce in e.g. ~/.profile, ~/.bash_profile etc?
    - Can you explain or show these cron scripts in CODE tags?
    - Do the crons work, if you are logged in locally via direct access to the machine or an out-of-band mechanism?
    You must always face the curtain with a bow.

  3. #3
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6
    Well sorry the SSH was just to explain I am remoted into the machine so it is accessed. However direct local logon is not possible this server is one of the clients on my ESXi server.

    Cron set-up:

    Code:
    # m h  dom mon dow   command
    0 5 * * * /bin/sh /home/ubuntu/alan/removesuccess.sh
    0 11 * * * /bin/sh /home/ubuntu/alan/dash.sh > success.txt
    */10 * * * * /bin/sh /var/www/tracker/tracker.sh
    */5 * * * * /bin/sh /home/ubuntu/alan/test.sh
    5 11 * * * /bin/sh /home/ubuntu/alan/success.sh

  4. $spacer_open
    $spacer_close
  5. #4
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6
    tracker.sh is as follows:

    Code:
    echo "Client Activity Tracker"
    echo ""
    #Version1 Alan Lumley
    ruby /var/www/tracker/callGordon.rb
    echo ""
    touch tracking.txt
    echo "Script completed" > tracking.txt

  6. #5
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6
    Quote Originally Posted by Irithori View Post
    Hi and welcome

    There is no obvious connection between cronjobs and a ssh session.
    - Do you maybe enable <whatever> ressorce in e.g. ~/.profile, ~/.bash_profile etc?
    - Can you explain or show these cron scripts in CODE tags?
    - Do the crons work, if you are logged in locally via direct access to the machine or an out-of-band mechanism?
    No such luck then

  7. #6
    Just Joined! msohail's Avatar
    Join Date
    Nov 2011
    Posts
    47
    Quote Originally Posted by lumleymedia View Post
    Well sorry the SSH was just to explain I am remoted into the machine so it is accessed. However direct local logon is not possible this server is one of the clients on my ESXi server.

    Cron set-up:

    Code:
    # m h  dom mon dow   command
    0 5 * * * /bin/sh /home/ubuntu/alan/removesuccess.sh
    0 11 * * * /bin/sh /home/ubuntu/alan/dash.sh > success.txt
    */10 * * * * /bin/sh /var/www/tracker/tracker.sh
    */5 * * * * /bin/sh /home/ubuntu/alan/test.sh
    5 11 * * * /bin/sh /home/ubuntu/alan/success.sh

    Change the file permission of all the above .sh scripts to 755. Next, login as "ubuntu" user and edit the crontab in the following fashion (only after making scripts with 755 permission)

    0 5 * * * /home/ubuntu/alan/removesuccess.sh
    or
    0 5 * * * /home/ubuntu/alan/./removesuccess.sh (yes, ./removesuccess.sh at the end)

    This will execute the script even if u logoff as ubuntu

    Of course the cron will fail when u execute the 3rd cron job in your list unless ubuntu has permission over /var/www/tracker directory.

    Hope this helps.

    Jazak Allah
    Sohail

  8. #7
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6
    Quote Originally Posted by msohail View Post
    Change the file permission of all the above .sh scripts to 755. Next, login as "ubuntu" user and edit the crontab in the following fashion (only after making scripts with 755 permission)

    0 5 * * * /home/ubuntu/alan/removesuccess.sh
    or
    0 5 * * * /home/ubuntu/alan/./removesuccess.sh (yes, ./removesuccess.sh at the end)

    This will execute the script even if u logoff as ubuntu

    Of course the cron will fail when u execute the 3rd cron job in your list unless ubuntu has permission over /var/www/tracker directory.

    Hope this helps.

    Jazak Allah
    Sohail
    Thanks Jazak, This is the root user account cron list.
    Therefore the permissions are already present. The scripts run fine unless I am logged out.

    The cron list I gave you was output from

    sudo crontab -l

    or

    sudo -i
    crontab -l

  9. #8
    Just Joined! msohail's Avatar
    Join Date
    Nov 2011
    Posts
    47

    Smile

    Quote Originally Posted by lumleymedia View Post
    Thanks Jazak, This is the root user account cron list.
    Therefore the permissions are already present. The scripts run fine unless I am logged out.

    The cron list I gave you was output from

    sudo crontab -l

    or

    sudo -i
    crontab -l

    Thanks lumlevmedia and the name is Sohail, not Jazak

    Even if the cron jobs are from root user, I would still recommend you to change the file permissions of scripts to 755 and follow the cron job format i mentioned in my previous post.

    Things should work out great.

    Jazak Allah,
    Sohail

  10. #9
    Just Joined!
    Join Date
    Jan 2013
    Posts
    6
    Quote Originally Posted by msohail View Post
    Thanks lumlevmedia and the name is Sohail, not Jazak

    Even if the cron jobs are from root user, I would still recommend you to change the file permissions of scripts to 755 and follow the cron job format i mentioned in my previous post.

    Things should work out great.

    Jazak Allah,
    Sohail
    Hmmm made the minor changes and still without being connected the client tracker does not update

    Really scratching my head with this one.

  11. #10
    Just Joined!
    Join Date
    Dec 2013
    Posts
    1
    Is the home directory of user 'ubuntu' encrypted? cron won't be able to access /home/ubuntu/... if so

    (I had this problem myself)

Posting Permissions

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