Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
2 Pages V   1 2 >  
Reply to this topicStart new topic
> My first cron script, Help me
{XN}Boylett
post Aug 28 2006, 05:28 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



In the crontab:

CODE
# Restart server
0,2 * * * * /server/sv_up.sh >/dev/null 2>&1



In sv_up.sh:

CODE
#!/bin/sh

mtaserverdir="/server/"
process=`ps auxw | grep linuxq3ded | grep -v grep | awk '{print $11}'`

if [ -z "$process" ]; then

  echo "Couldn't find MTA Server running, restarting it."
  cd "$mtaserverdir"
  nohup ./mtaserver +exec ffa.cfg &
  echo ""

fi


What im trying to do is make sv_up.sh run every 2 minutes.
And what I want sv_up.sh to do is start mtaserver.exe if it isnt running
Can anyone help me? It doesnt work dry.gif
Go to the top of the page
 
+Quote Post
michaelk
post Aug 28 2006, 06:21 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



Does the script run successfully from the console?
0,2 * * ... means runs on 0 and 2 minutes or every hour not every 2 minutes. */2 means every two minutes.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 28 2006, 06:42 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



QUOTE (michaelk @ Aug 28 2006, 12:21 PM) *
Does the script run successfully from the console?
0,2 * * ... means runs on 0 and 2 minutes or every hour not every 2 minutes. */2 means every two minutes.


does that mean */2 * * * * *
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 28 2006, 07:33 AM
Post #4


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



CODE
# Restart server
*/2 * * * * /server/sv_up.sh >/dev/null 2>&1


Gets me an error message
Go to the top of the page
 
+Quote Post
michaelk
post Aug 28 2006, 09:44 AM
Post #5


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



What is the error message?
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 28 2006, 11:41 AM
Post #6


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



QUOTE (michaelk @ Aug 28 2006, 03:44 PM) *
What is the error message?


CODE
28.08.2006 13:28 Cron started.
28.08.2006 13:29 Error in crontab, line 4: improper value.
Go to the top of the page
 
+Quote Post
michaelk
post Aug 28 2006, 12:11 PM
Post #7


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



*/2 * * * * /server/sv_up.sh >/dev/null 2>&1

Is this line 4?
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 29 2006, 07:04 AM
Post #8


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



QUOTE (michaelk @ Aug 28 2006, 06:11 PM) *
*/2 * * * * /server/sv_up.sh >/dev/null 2>&1

Is this line 4?

Yes
Go to the top of the page
 
+Quote Post
michaelk
post Aug 29 2006, 10:17 AM
Post #9


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



I do not see anything obvoiusly wrong with the line.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 29 2006, 03:31 PM
Post #10


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



Would it help if i said i get the error about 2 minutes after starting cron and in the cron.log ?
Go to the top of the page
 
+Quote Post
michaelk
post Aug 29 2006, 04:53 PM
Post #11


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



Try changing the line to
* * * * * /server/sv_up.sh >/dev/null 2>&1

This will run the script every minute.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Aug 30 2006, 02:15 PM
Post #12


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



QUOTE (michaelk @ Aug 29 2006, 10:53 PM) *
Try changing the line to
* * * * * /server/sv_up.sh >/dev/null 2>&1

This will run the script every minute.


thats works fine. also how do u turn cron off once started it? lol tongue.gif
Go to the top of the page
 
+Quote Post
michaelk
post Aug 30 2006, 04:34 PM
Post #13


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



All I can say is interesting. I'm not sure what is going on here at the moment. You can turn of cron but that will stop all other jobs too.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Sep 11 2006, 01:55 PM
Post #14


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



oh well im happy it doing that every minute. anyway, about this shell script...
CODE
#!/bin/sh

mtasadir="/server_windows"
process=`ps auxw | grep linuxq3ded | grep -v grep | awk '{print $11}'`

if [ -z "$process" ]; then

  echo "Couldn't find MTA running, restarting it."
  cd "$mtasadir"
  nohup ./mtaserver +exec ffa.cfg &
  echo ""

fi

This code should start a program called mtaserver.exe, but it doesnt. cron runs it and it opens, but the server doesnt start. can anyone fix it?
Go to the top of the page
 
+Quote Post
michaelk
post Sep 11 2006, 03:36 PM
Post #15


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



Does the script work running from a console?
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Sep 13 2006, 11:32 AM
Post #16


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



Sorry, what does that mean? I run Cron on my computer. The Crontab and sv_up.sh are both in the same file
Go to the top of the page
 
+Quote Post
michaelk
post Sep 13 2006, 03:40 PM
Post #17


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



cron at the scheduled time executes the script sv_up.sh. You should be able to execute this same script manually from terminal window.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Sep 13 2006, 05:26 PM
Post #18


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



Whats a terminal window?
Go to the top of the page
 
+Quote Post
michaelk
post Sep 13 2006, 05:36 PM
Post #19


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,800
Joined: 23-January 03
Member No.: 360



A console or terminal window is an application typically called xterm. It is similar to the windows DOS prompt box i.e c:\. So you would type in the command
/server/sv_up.sh

On the desktop toobar there is an icon that looks like a video monitor. This should start xterm.
Go to the top of the page
 
+Quote Post
{XN}Boylett
post Sep 14 2006, 10:59 AM
Post #20


Whats this Lie-nix Thing?
*

Group: Members
Posts: 18
Joined: 27-August 06
Member No.: 7,075



i have windows xp. how do i start it?
Go to the top of the page
 
+Quote Post

2 Pages V   1 2 >
Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 23rd November 2017 - 07:03 PM