LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-12-2013, 08:52 AM   #16
shivaa
Senior Member
 
Registered: Jul 2012
Location: Grenoble, Fr.
Distribution: Sun Solaris, RHEL, Ubuntu, Debian 6.0
Posts: 1,800
Blog Entries: 4

Rep: Reputation: 286Reputation: 286Reputation: 286

Quote:
Originally Posted by Wover View Post
Hurray! It works . In the last edits I left out username variable in the crontab lines. Thanks to all!
Following should have worked:
Code:
0 3 * * * "cd /var/scripts; ./serverbackup.sh > /tmp/backup_logs"
OR
0 3 * * * "/var/scripts/serverbackup.sh > /tmp/backup_logs"
Did you try this? If not, what did you do?
 
Old 03-12-2013, 08:57 AM   #17
Wover
LQ Newbie
 
Registered: Mar 2013
Posts: 9

Original Poster
Rep: Reputation: Disabled
So:

1) Get the $PATH for the user you are running the script with and paste it under PATH in the crontab file
2) put /bin/sh in front of the command and don't forget the username either

Troubleshooting steps:

1) output some command to a file every minute, for example * * * * * root env > /tmp/env_output
2) If no output, check if crond is running
3) If output, try running the command manually from the shell and correct any errors that occur
 
Old 03-12-2013, 09:56 PM   #18
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,241

Rep: Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325Reputation: 2325
If the script has executable perms and has the first line '#!/bin/bash' (normal setup), then no need for eg /bin/sh in cron entry.
Speaking of which, if you use that approach, select the exact shell you want eg either sh or bash; they're not the same thing.
For portability I ALWAYS put the correct one in the first line of the script and use execute perms.
Also, I'd put the PATH inside the script for the same reason. It makes cron less cluttered and not all scripts need the same PATH.
 
  


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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Automated dcraw and cjpeg script from crontab henkka Programming 3 01-05-2012 03:33 PM
automated backup GameSky Linux - Software 23 06-18-2007 02:57 AM
Automated HD backup General Linux - Hardware 3 05-11-2006 09:39 PM
Automated Backup via FTP KePSuX Linux - Newbie 3 02-11-2004 09:25 AM
automated FTP backup josephswagner Linux - Software 2 06-06-2003 05:42 PM


All times are GMT -5. The time now is 02:34 AM.

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