LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
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 10-09-2011, 07:18 AM   #1
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Rep: Reputation: 15
crontab not working


ok so i sorted out my script and set up crontab

i used sudo crontab -e to load it
i choose nano as my editor (i get on with nano...vi hates me)

i want the script called autorestart.sh thats in the home folder of a user called mine craft to run every day at 0500 and to start with output to autolog.log

so the line i add is

0 5 * * * /home/minecraft/autorestart.sh 2>&1 >> /home/minecraft/autolog.log
Code:
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   command
0 5 * * * /home/minecraft/autorestart.sh 2>&1 >> /home/minecraft/autolog.log
as i understood it
0(minutes) 5(5 am) *(every day of the month) *(everymonth) *(every day) /home/minecraft/autorestart.sh(the script) 2>&1 >>(i have no idea?) /home/minecraft/autolog.log(where u want it to send screen output to)

but at 5am nothing happened
i went to check the autolog.log....there is no autolog.log so im guessing it hadnt even attempted the line!

i thought maybe its because its decided to save it in a tmp folder (at the top of nano it says /tmp/crontab.xqAb3k/crontab but then if it sudo crontab -e can read it and bring the changes back up then crontab should as well?

im stuck basicly!
 
Old 10-09-2011, 08:28 AM   #2
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Is crond running? Which distribution? Did you do chmod a+x on autorestart.sh? Does your script start with the standard shebang?
 
Old 10-09-2011, 08:37 AM   #3
hen770
Member
 
Registered: Oct 2010
Distribution: Arch
Posts: 136

Rep: Reputation: 7
Quote:
Originally Posted by rch:4493786
Does your script start with the standard shebang?
What kind of shebang a bash script should start with?
 
Old 10-09-2011, 08:46 AM   #4
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rch View Post
Is crond running? Which distribution? Did you do chmod a+x on autorestart.sh? Does your script start with the standard shebang?
crond running.... no idea though if i can issue sudo crontab -e surely that means its running?

distribution: ubunutu 64bit, terminal access only (were running a minecraft server that i use putty access to)
the script is chmod 777 i have tested it seperatly with ./autorestart.sh and it runs perfectly
shebang? i feel it has a certain kabow but i may be bias as i created it ....

Code:
#!/bin/sh
screen -S max -X stuff "say nightly back up in 6 minutes Please log off"
screen -S max -X eval "stuff \015"
sleep 5
screen -S max -X stuff "say Max apologises for the inconvience"
screen -S max -X eval "stuff \015"
sleep 5
screen -S max -X stuff "say down time liable to be short"
screen -S max -X eval "stuff \015"
sleep 50
screen -S max -X stuff "say server shutdown for backup in 5 minutes"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 4 minutes"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 3 minutess"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 2 minutess"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 1 munute"
screen -S max -X eval "stuff \015"
sleep 30
screen -S max -X stuff "save-all"
screen -S max -X eval "stuff \015"
sleep  10
screen -S max -X stuff "say server shutdown for backup in 30 seconds"
screen -S max -X eval "stuff \015"
sleep 20
screen -S max -X stuff "say 10 seconds... log out now"
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 9 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 8 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 7 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 6 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 5 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 4 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 3 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "memory -f"
screen -S max -X eval "stuff \015"
sleep 3
screen -S max -X stuff "say 2 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 1 "
screen -S max -X eval "stuff \015"
sleep 1
# screen -S max -X stuff "say if only we had a kick all command"
# screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "stop"
screen -S max -X eval "stuff \015"
sleep 30
/home/minecraft/backupserver.sh
screen -S max -X stuff "./start.sh "
screen -S max -X eval "stuff \015"
sleep 2
the script it runs too
Code:
exec 1>/home/minecraft/backup.log 2>&1 
#!/bin/sh
BACKUP="/home/minecraft/backup"
ACTIVE="/home/minecraft/minecraft_server/"
rsync -r -t -v "$ACTIVE" "$BACKUP"
im sure i must of missed up the crontab bit as it doesnt even create the autolog.log file
 
Old 10-09-2011, 09:08 AM   #5
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Quote:
Originally Posted by hen770 View Post
What kind of shebang a bash script should start with?
How about
Code:
#!/bin/bash
. That may not be needed if you defined
Code:
SHELL=/bin/bash
in your crontab.
 
Old 10-09-2011, 09:12 AM   #6
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Even if you are able to issue crontab -e, crond may not be running. A simple
Code:
ps aux|grep crond
should tell you whether crond is running or not. Also check /var/log/crond.

Quote:
Originally Posted by mrgreaper View Post
crond running.... no idea though if i can issue sudo crontab -e surely that means its running?

distribution: ubunutu 64bit, terminal access only (were running a minecraft server that i use putty access to)
the script is chmod 777 i have tested it seperatly with ./autorestart.sh and it runs perfectly
shebang? i feel it has a certain kabow but i may be bias as i created it ....

Code:
#!/bin/sh
screen -S max -X stuff "say nightly back up in 6 minutes Please log off"
screen -S max -X eval "stuff \015"
sleep 5
screen -S max -X stuff "say Max apologises for the inconvience"
screen -S max -X eval "stuff \015"
sleep 5
screen -S max -X stuff "say down time liable to be short"
screen -S max -X eval "stuff \015"
sleep 50
screen -S max -X stuff "say server shutdown for backup in 5 minutes"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 4 minutes"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 3 minutess"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 2 minutess"
screen -S max -X eval "stuff \015"
sleep 60
screen -S max -X stuff "say server shutdown for backup in 1 munute"
screen -S max -X eval "stuff \015"
sleep 30
screen -S max -X stuff "save-all"
screen -S max -X eval "stuff \015"
sleep  10
screen -S max -X stuff "say server shutdown for backup in 30 seconds"
screen -S max -X eval "stuff \015"
sleep 20
screen -S max -X stuff "say 10 seconds... log out now"
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 9 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 8 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 7 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 6 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 5 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 4 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 3 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "memory -f"
screen -S max -X eval "stuff \015"
sleep 3
screen -S max -X stuff "say 2 "
screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "say 1 "
screen -S max -X eval "stuff \015"
sleep 1
# screen -S max -X stuff "say if only we had a kick all command"
# screen -S max -X eval "stuff \015"
sleep 1
screen -S max -X stuff "stop"
screen -S max -X eval "stuff \015"
sleep 30
/home/minecraft/backupserver.sh
screen -S max -X stuff "./start.sh "
screen -S max -X eval "stuff \015"
sleep 2
the script it runs too
Code:
exec 1>/home/minecraft/backup.log 2>&1 
#!/bin/sh
BACKUP="/home/minecraft/backup"
ACTIVE="/home/minecraft/minecraft_server/"
rsync -r -t -v "$ACTIVE" "$BACKUP"
im sure i must of missed up the crontab bit as it doesnt even create the autolog.log file
 
Old 10-09-2011, 01:11 PM   #7
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rch View Post
Even if you are able to issue crontab -e, crond may not be running. A simple
Code:
ps aux|grep crond
should tell you whether crond is running or not. Also check /var/log/crond.
that resulted in
Code:
minecraft@ubuntu:~$ ps aux|grep crond
1000     27244  0.0  0.0  13124  1064 pts/0    S+   19:05   0:00 grep --color=auto crond
red normaly means bad...how do i make it green?

sorry but i looked at loads of crontab guides and they all seem to assume that crontab is loaded and running by default

/var/log/crond. didnt exist, infact no file starting cron at all

i have used linux on and off for 5 years, more off then on and i still find it serously confusing, however now i know what a shebang is (i actualy thought you guys were playing the lets confuse the newbie came, like asking a builders apprentice for a left handed screwdriver...sorry for my kapow reply)
 
Old 10-09-2011, 03:04 PM   #8
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Quote:
Originally Posted by mrgreaper View Post
that resulted in
Code:
minecraft@ubuntu:~$ ps aux|grep crond
1000     27244  0.0  0.0  13124  1064 pts/0    S+   19:05   0:00 grep --color=auto crond
red normaly means bad...how do i make it green?
Sorry my bad. Please do a
Code:
 ps aux|grep cron
- for Ubuntu. If it returns two lines, then crond is running fine. And there is no /var/log/crond in Ubuntu. Most likely, the log for cron is /var/log/syslog. So, do
Code:
less /var/log/syslog|grep -i cron
to see if you can find what is happening.

Quote:
i have used linux on and off for 5 years, more off then on and i still find it serously confusing, however now i know what a shebang is (i actualy thought you guys were playing the lets confuse the newbie came, like asking a builders apprentice for a left handed screwdriver...sorry for my kapow reply)
I have been using Linux for 12 years and I also find it confusing at times. So, don't worry. That's why Google and LinuxQuestions exist, don't you think?
 
Old 10-09-2011, 08:10 PM   #9
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rch View Post
Sorry my bad. Please do a
Code:
 ps aux|grep cron
- for Ubuntu. If it returns two lines, then crond is running fine. And there is no /var/log/crond in Ubuntu. Most likely, the log for cron is /var/log/syslog. So, do
Code:
less /var/log/syslog|grep -i cron
to see if you can find what is happening.


I have been using Linux for 12 years and I also find it confusing at times. So, don't worry. That's why Google and LinuxQuestions exist, don't you think?
Code:
minecraft@ubuntu:~$ less /var/log/syslog|grep -i cron
Oct  9 07:44:37 ubuntu anacron[24310]: Job `cron.daily' terminated (mailing outp                                                                                                                                                             ut)
Oct  9 07:44:37 ubuntu anacron[24310]: Can't find sendmail at /usr/sbin/sendmail                                                                                                                                                             , not mailing output
Oct  9 07:44:37 ubuntu anacron[24310]: Normal exit (1 job run)
Oct  9 08:09:01 ubuntu CRON[28105]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 08:17:01 ubuntu CRON[28850]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 08:39:01 ubuntu CRON[30965]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 09:09:01 ubuntu CRON[1374]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 09:17:01 ubuntu CRON[2153]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 09:39:01 ubuntu CRON[4186]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 10:09:01 ubuntu CRON[6952]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 10:17:01 ubuntu CRON[7700]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 10:39:02 ubuntu CRON[9719]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 11:09:01 ubuntu CRON[12488]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 11:17:01 ubuntu CRON[13252]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 11:39:01 ubuntu CRON[15307]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 12:09:01 ubuntu CRON[18203]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 12:17:01 ubuntu CRON[18954]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 12:32:36 ubuntu crontab[20733]: (root) BEGIN EDIT (root)
Oct  9 12:33:13 ubuntu crontab[20733]: (root) END EDIT (root)
Oct  9 12:39:01 ubuntu CRON[21417]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 12:57:27 ubuntu crontab[23230]: (root) BEGIN EDIT (root)
Oct  9 13:09:01 ubuntu CRON[24337]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 13:16:01 ubuntu crontab[23230]: (root) END EDIT (root)
Oct  9 13:16:42 ubuntu crontab[25105]: (root) BEGIN EDIT (root)
Oct  9 13:17:01 ubuntu CRON[25147]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 13:19:13 ubuntu crontab[25105]: (root) END EDIT (root)
Oct  9 13:39:01 ubuntu CRON[27268]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 14:09:01 ubuntu CRON[30200]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 14:17:01 ubuntu CRON[30973]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 14:39:01 ubuntu CRON[658]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime ]                                                                                                                                                              && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1 -                                                                                                                                                             type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 15:09:02 ubuntu CRON[4017]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 15:17:01 ubuntu CRON[4847]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 15:39:01 ubuntu CRON[7002]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 16:09:01 ubuntu CRON[9818]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 16:17:01 ubuntu CRON[10607]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 16:39:01 ubuntu CRON[12717]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 17:09:01 ubuntu CRON[15944]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 17:17:01 ubuntu CRON[16715]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 17:39:01 ubuntu CRON[18778]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 18:09:01 ubuntu CRON[21665]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 18:17:01 ubuntu CRON[22419]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 18:39:01 ubuntu CRON[24497]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 19:09:01 ubuntu CRON[27642]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 19:17:01 ubuntu CRON[28444]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 19:39:01 ubuntu CRON[30647]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 20:09:01 ubuntu CRON[1317]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 20:17:01 ubuntu CRON[2164]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 20:39:01 ubuntu CRON[4586]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 20:58:25 ubuntu cron[728]: (CRON) INFO (pidfile fd = 3)
Oct  9 20:58:25 ubuntu anacron[775]: Anacron 2.3 started on 2011-10-09
Oct  9 20:58:25 ubuntu cron[779]: (CRON) STARTUP (fork ok)
Oct  9 20:58:25 ubuntu cron[779]: (CRON) INFO (Running @reboot jobs)
Oct  9 20:58:25 ubuntu anacron[775]: Normal exit (0 jobs run)
Oct  9 20:58:26 ubuntu anacron[932]: Anacron 2.3 started on 2011-10-09
Oct  9 20:58:26 ubuntu anacron[932]: Normal exit (0 jobs run)
Oct  9 20:58:25 ubuntu anacron[1447]: Anacron 2.3 started on 2011-10-09
Oct  9 20:58:25 ubuntu anacron[1447]: Normal exit (0 jobs run)
Oct  9 21:09:01 ubuntu CRON[1809]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 21:17:01 ubuntu CRON[1817]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 21:39:01 ubuntu CRON[3075]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 22:09:01 ubuntu CRON[6425]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 22:17:01 ubuntu CRON[7377]: (root) CMD (   cd / && run-parts --report /et                                                                                                                                                             c/cron.hourly)
Oct  9 22:39:01 ubuntu CRON[10026]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 23:09:01 ubuntu CRON[13199]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct  9 23:17:01 ubuntu CRON[14169]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct  9 23:39:02 ubuntu CRON[16814]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct 10 00:09:01 ubuntu CRON[20466]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct 10 00:17:01 ubuntu CRON[21317]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct 10 00:39:01 ubuntu CRON[24191]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct 10 01:09:01 ubuntu CRON[27342]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1                                                                                                                                                              -type f -cmin +$(/usr/lib/php5/maxlifetime) -delete)
Oct 10 01:17:01 ubuntu CRON[28268]: (root) CMD (   cd / && run-parts --report /e                                                                                                                                                             tc/cron.hourly)
Oct 10 01:39:01 ubuntu CRON[30820]: (root) CMD (  [ -x /usr/lib/php5/maxlifetime                                                                                                                                                              ] && [ -d /var/lib/php5 ] && find /var/lib/php5/ -depth -mindepth 1 -maxdepth 1
and it had the two lines .... could it be as simple as since autolog.log didnt exist it errored instead of making it?



i removed the line that placed the out put into a log file

and the scrip was called...but nothing happened


Oct 10 02:20:01 ubuntu CRON[3271]: (root) CMD (/home/minecraft/autorestart.sh)

Last edited by mrgreaper; 10-09-2011 at 08:23 PM.
 
Old 10-09-2011, 08:42 PM   #10
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
AHA
i have found the problem,sort of though not the solution

when i run the script autorestart with ./autorestart.sh all is fine it works great

but the output from autolog.log (i created it and now its being used) is full off..

Quote:
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
No screen session found.
is it due to the fact user minecraft created the screen...the script is being run by user root cant see it?
if so how do i make user root see it?
 
Old 10-09-2011, 09:59 PM   #11
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
Why run rsync using screen? Beats me. Why you don't just run the script that has the rsync (which appears to do the real work) from your cron?
 
Old 10-09-2011, 10:15 PM   #12
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rch View Post
Why run rsync using screen? Beats me. Why you don't just run the script that has the rsync (which appears to do the real work) from your cron?
because if we rsync while the server is active bad things happen, better to bring it down first
we also want the server to be brought down for more then backup, so it can have that fresh just started server feel to the players every day
screens are needed too as we remote into it using putty and similier
 
Old 10-09-2011, 10:45 PM   #13
rch
Member
 
Registered: Feb 2003
Location: Santa Clara,CA
Distribution: Mandriva
Posts: 909

Rep: Reputation: 48
You can probably bring down your server and then run rsync without using screen -just by updating your script. Which script brings down your server?
 
Old 10-09-2011, 10:58 PM   #14
mrgreaper
Member
 
Registered: May 2006
Posts: 167

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by rch View Post
You can probably bring down your server and then run rsync without using screen -just by updating your script. Which script brings down your server?
thier both on post 4

i need to use screen so i can input test into the console of the server

ran with ./autorestart.sh it functions beautifuly
ran from cron the no screen session found error
 
Old 10-10-2011, 01:07 AM   #15
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,356

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
The default cron env is minimal; you should use full absolute paths to every cmd & file referenced, or set up the correct env (eg via 'source' cmd) at the top of your shell script (after #!/bin/bash) on next line(s).
See /var/log/cron (at least on RH) for cron msgs.
Also, if cron itself has an issue, it'll email the job owner or root.

Also amend cron cmd
Code:
0 5 * * * /home/minecraft/autorestart.sh >> /home/minecraft/autolog.log 2>&1
 
1 members found this post helpful.
  


Reply



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
Crontab is not working, the script is working arfal SUSE / openSUSE 6 02-08-2010 08:48 PM
crontab not working mahmoud Linux - Newbie 16 07-11-2008 12:46 PM
crontab not working durgap Linux - General 6 09-01-2005 02:38 PM
crontab nor working navaladi Mandriva 11 01-17-2005 06:58 AM
crontab not working subaruwrx Linux - Newbie 8 08-17-2004 09:12 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:12 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
Open Source Consulting | Domain Registration