LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 04-18-2012, 06:57 AM   #1
norwichnick
LQ Newbie
 
Registered: May 2005
Location: Norwich, Norfolk, UK
Distribution: Ubuntu 10.04 LTS
Posts: 9

Rep: Reputation: 0
Question Script not running after reboot


Hi everyone,

I have a Ubuntu 10.04 LTS (Desktop) box that I am trying to backup with a script that's automatically triggered in a user's crontab with limited success.

The script exports data from the local MySQL server, uses GZip to compress it and then uses FTP to send it over the Internet to another computer.

I have tested the file after making it executable, and everything works to plan; there's a local backup of the DB, and the file is received on the remove server - no problem.

My problem comes when scheduling it. I currently have it on a schedule to run every hour at 15 minutes past between 08:15 and 18:15. The entry on my crontab looks as follows:
Code:
15 8 * * 1,2,3,4,5 /full/path/to/script.sh
15 9 * * 1,2,3,4,5 /full/path/to/script.sh
and so on ...
I know that I can use 8-18 and 1-5 to specify hour and day ranges ... This is how it's set out whilst testing.

If I SSH to the box and run the backup as the user that has it on their crontab, it runs fine. The job will then continue to run through until 18:15, and resume again at 08:15.

However, if the box is restarted/powered off; the schedule stops. Going back in to the crontab and saving it doesn't 'rescue' it.

The only thing that seems to rescue it running the script manually whilst connected to SSH. It will then continue to run on schedule as normal.

Any ideas as to what may be causing my insanity?

Any helps is massively appreciated!

All the best,
Nick
 
Old 04-18-2012, 07:09 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 11,287

Rep: Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393Reputation: 3393
I would insert some log into that script, like
Code:
echo scriptname started at >> logfile
date >> logfile
...
echo scriptname finished >> logfile
date >> logfile
also I would try to redirect stdout and stderr of the crontab entry
Code:
15 9 * * 1,2,3,4,5 /full/path/to/script.sh >>/full/path/to/log.stdout 2>>/full/path/to/log.stderr
maybe you can catch some error...

Last edited by pan64; 04-18-2012 at 07:12 AM.
 
1 members found this post helpful.
Old 04-18-2012, 07:32 AM   #3
dayid
Member
 
Registered: Apr 2012
Location: Austin, TX
Posts: 44

Rep: Reputation: Disabled
In addition to what pan64 suggested - just a thought:

Do you happen to use encrypted home directories and have the full path of the script as somewhere in the user's home directory? Scripts wouldn't be run because the user's home directory is encrypted, and since the user wasn't logged in, the encrypted home directory was not mounted, thus cron could not access/read the script. However, presuming mail is configured correctly, you'd still receive an error mail about this situation to the user's account.
 
1 members found this post helpful.
Old 04-19-2012, 03:35 AM   #4
norwichnick
LQ Newbie
 
Registered: May 2005
Location: Norwich, Norfolk, UK
Distribution: Ubuntu 10.04 LTS
Posts: 9

Original Poster
Rep: Reputation: 0
Thank you pan64 and dayid for your replies!

pan64, I shall have to remember to turn on logging when messing around with scripts in the future.

dayid, you've saved my day. I've moved the backup script to /etc and changed where the backup dumps the database files to the same directory and gave it a test run. It worked fine, then I powered down the box at the end of the day. I've turned it on first thing this morning, checked it an hour later, and I have a backup come through that's run perfectly on schedule.

Thank you so much!

All the best,
Nick
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell Script to start a program either not running or kill if running avataratar Linux - Newbie 1 03-29-2012 02:45 AM
Fighting with making running a script at startup only but not at shutdown/reboot ... Xeratul Debian 5 12-01-2010 01:13 PM
xend not running after reboot geo75 Linux - Server 2 09-07-2009 04:44 PM
running screen with irssi after reboot Ateos Linux - General 2 08-27-2006 07:53 AM
Module running after reboot? Dark Severance Red Hat 6 04-19-2005 07:02 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration