Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 02-18-2004, 10:27 PM   #1
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Rep: Reputation: 30
Starting a service in a bash script

Hey all

This is a reasonably simple one but a quirky one...

I've got a script that stops squid and then restarts it.. basically, I have service start squid in the script and it seems to run fine but when I run it as a cron job it doesn't actually start squid... anyone got any ideas? I don't get any errors etc in the logs to point out anything....
Old 02-18-2004, 10:50 PM   #2
Registered: Sep 2003
Location: United Kingdom
Distribution: Ubuntu, Arch
Posts: 438

Original Poster
Rep: Reputation: 30
Ummmm k just checked mail and it's been leaving messages - can't just use service in bash...

---- Update ----

It runs perfectly if i just type the name of the script (and thats just got "service squid start" in it) yet as a cron job it barfs saying that it doesn't know the service command... anyone got any ideas

Last edited by AMMullan; 02-18-2004 at 10:56 PM.
Old 02-19-2004, 06:19 AM   #3
Registered: Jan 2004
Location: Munich
Distribution: SuSE 9.2, 10.2, 10.3, knoppix
Posts: 276

Rep: Reputation: 31
One possible cause I can think of: cron (as any other process) needs
the rights to do what it wants to do - so if you want users x cron to start user y's scripts which only root and y may access, then it will fail.
Old 02-19-2004, 11:06 AM   #4
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
Cron uses its own PATH I believe. I think it cannot find the "service" executable in the path, so you need to specify the full path to "service", or include the directory where it lives in the PATH of crontab.


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
starting this as a service. dkc_ace Linux - General 15 12-27-2004 09:31 PM
Won't Boot - Starting Printer Service - Starting CUPS jeansond Linux - Newbie 0 10-11-2004 06:39 PM
Bash backup script - If multiple files starting with a exist problem demoncheese Programming 2 07-29-2004 10:47 PM
bash script to stop isdn service after x mintus? paul.nel Programming 4 03-11-2004 10:01 AM
starting one service before the other in Rh jayakrishnan Linux - General 2 11-19-2003 12:32 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:31 AM.

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