Sponsored Content
Top Forums UNIX for Advanced & Expert Users Crontab Eintrag geht nicht... bitte um hilfe Post 302342367 by bakunin on Sunday 9th of August 2009 07:02:53 AM
Old 08-09-2009
Quote:
Originally Posted by Neo
Hello.

Per our forum rules, all posts must be in English.
As a service to the public i translated the first three posts to english. I hope you all understand the rule, which ensures that the biggest possible share of users can participate in the forums. Like it or not, English is the de facto lingua franca of the internet.


Quote:
Hello,

i try to insert a line in crontab to start a script for my Anti-Flood-tool after every boot of the server. Unfortunately i am not all too knowledgable about Linux. Maybe someone could help me?

Thanks a lot in advance.

---> The entry i wrote:
Code:
@reboot ./teamspeak/ts2afd_startscript start

I use a similar line to start the Ts which is working flawlessly

Code:
@reboot /teamspeak/tss2_rc2/server_linux

Quote:
Hello.

Please post the complete crontab-entry.

Additionally the leading fullstop:

Code:
./teamspeak/ts2afd_startscript start

should be deleted.

Which shell do you use?
Quote:
Code:
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.XXXX1eso9q installed on Sat Aug  8 16:08:25 2009)
# (Cron version V5.0 -- $Id: crontab.c,v 1.12 2004/01/23 18:56:42 vixie Exp $)
@reboot /teamspeak/ts2afd_startscript start
@reboot /teamspeak/tss2_rc2/server_linux
34      0       *       *       *       /usr/local/psa/bin/run-parts.sh /etc/psa/plesk-cron.daily
44      5       *       *       7       /usr/local/psa/bin/run-parts.sh /etc/psa/plesk-cron.weekly
50      1       1       *       *       /usr/local/psa/bin/run-parts.sh /etc/psa/plesk-cron.monthly
11,26,41,56     *       *       *       *       /usr/local/psa/admin/sbin/backupmng >/dev/null 2>&1
0       1       *       *       1       /usr/local/psa/libexec/modules/watchdog/cp/secur-check
0       1       *       *       1       /usr/local/psa/libexec/modules/watchdog/cp/send-report weekly
10      1       *       *       *       /usr/local/psa/libexec/modules/watchdog/cp/clean-sysstats
15      1       *       *       *       /usr/local/psa/libexec/modules/watchdog/cp/pack-sysstats day
15      1       *       *       1       /usr/local/psa/libexec/modules/watchdog/cp/pack-sysstats week
15      1       1       *       *       /usr/local/psa/libexec/modules/watchdog/cp/pack-sysstats month
15      1       1       *       *       /usr/local/psa/libexec/modules/watchdog/cp/pack-sysstats year
20      1       *       *       *       /usr/local/psa/libexec/modules/watchdog/cp/clean-events
0       3       *       *       7       /usr/local/psa/libexec/modules/watchdog/cp/clean reports

---------- Post updated at 09:25 AM ---------- Previous update was at 09:24 AM ----------

Unfortunately i don't know how to find which shell i use. I have to admit .... i have to learn a lot still ... haven't much experience with Linux up to now. :-(
Now to the problem itself:

I don't know Linux all too well, but crontab is not the place to do things based on a event, like a reboot. crontab is for doing things repetitively based on time: if you want to run a script every 5 minutes or every third monday in a month or everyday at 5:00 pm, you use cron. In your case you use a "rc-script". The basic design is like that: your system has several different "runlevels" - modes of operation. One runlevel is a single-user mode without any networking, wich is used to debug the system if things went really, really bad. Another runlevel is multi-user, full network, but no graphical login, which is good if your graphics adapter is broken and you have to log on over the network. Read more about runlevels in your man pages.

To change from one runlevel to another there is a command ("telinit"). When this command is issued the following happens: all the services started in this runlevel are stopped (killed), then the runlevel is switched and all the services in the new runlevel are started. Because at boot time there has to be some runlevel initialized all the start-scripts for this runlevel are executed. This stopping/starting is done via so-called "rc-scripts", which reside in "/etc/rc[n].d", where [n] is the number of the runlevel. all these scripts work the same way: they understand a single parameter, which can be "start", "stop" (or "restart").

Here is a basic layout for such an rc-script:

Code:
case "$1" in
     start)
          # ---- do everything to start service here
          ;;

     stop)
          # ---- do everything to stop service here
          ;;

     *)
          echo "Usage: rc-script {start|stop}"
                exit 1
                ;;
esac

exit 0

You could put your command in there instead of in the crontab and it should work. That is: if your command would be correct, which it isn't.

If you use a relative path like "./somewhere" you depend on a specific context: your session has a working directory, in which a directory named "somewhere" resides. If you would change into this directory the path "./somewhere" would not make sense any more, right? When this script is executed (and this is true for crontab scripts alike) there is no such thing as context, because this is not your session any more, but a different one - hence, use absolute paths always!

Furthermore, you might have set environment variables your application depends on. Be aware that these won't be set in an rc-script either. You have to set them there explicitly to be able to use them there. Issue an "env" and analyze the output to find out if this is true for your app.

I hope this helps.

bakunin

Last edited by bakunin; 08-09-2009 at 08:12 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

crontab

Hi I have a shell script which works fine at the command line and does works in crontab also but does not send the output to mail as other scripts do by default. 10 1 * * * /export/home/test/report_script by default should send the output to mail but the script runs OK and the output... (1 Reply)
Discussion started by: run_time_error
1 Replies

2. UNIX for Dummies Questions & Answers

crontab help

Hi All, Please help me in understanding the crontab entries and also below queries 1. how can we set a crontab entry 2. from where the cronjob will run( if default) 3. you can we specify the location from which the cronjob should run. 4. how can we capture the output of the cronjob. ... (8 Replies)
Discussion started by: thaduka
8 Replies

3. UNIX for Dummies Questions & Answers

Crontab

How can I run "crontab" (parameters) every 6 hours on solaris machine? Thanks (1 Reply)
Discussion started by: gen4ik
1 Replies

4. Shell Programming and Scripting

help with crontab

i have a ksh script that creates messages in a temp directory and then sends them out using the sendmail command and i'm trying to set it up to run every night with crontab. So the basic gist of the script is #create temp dir and messages ... #loop through each message and send using sendmail... (3 Replies)
Discussion started by: bob122480
3 Replies

5. Shell Programming and Scripting

Using Crontab

Hi All, I've a shell script which calls a Sybase stored procedure to do some functionality. I want to schedule the running of this script by crontab. I'm using Solaris 5.8. When i executed the following command crontab -l i got the output as crontab: can't open your crontab file How... (10 Replies)
Discussion started by: sumesh.abraham
10 Replies

6. HP-UX

Crontab

Is it possible to add a line to a crontab to so that a program will run every 15 minutes? how will this line look? Thank you. (10 Replies)
Discussion started by: NicoMan
10 Replies

7. Solaris

crontab

Hi I have an entry in the cron file. 10 3 * * * /usr/bin/test.sh I want to change it to: 00 11 * * * /usr/bin/test.sh how to do this without entering the crontab file and edit the change? thank you (5 Replies)
Discussion started by: melanie_pfefer
5 Replies

8. UNIX for Dummies Questions & Answers

Brauche SCHNELLE HILFE

Hallo, ich habe folgende Dateien: 1Lmr12345.orig 1Lmr23456.orig 1Lmr34567.orig Davon allerdings hunderte. Wie lautet der Befehl um diese Dateien umzubenennen in 1Lmr12345 1Lmr23456 1Lmr34567 also ohne die Endung und ohne den Punkt? Weiß einer was????? (1 Reply)
Discussion started by: FranzB
1 Replies

9. Shell Programming and Scripting

Hilfe beim SCRIPT

Hallo, unter Suse Linux 11.2 / Kubuntu 10.04 habe ich mir ein Service-Menü angelegt. Bis auf das Nachfolgende funktioniert alles bestens. Bisher habe ich auf der Konsole mit dem Programm pdftk Anhänge an ein Pdf-File erzeugt. Der Code lautete pdftk beispiel.pdf attach_files Anlage1.pdf... (1 Reply)
Discussion started by: Hannes_007
1 Replies

10. OS X (Apple)

OS 10 lässt sich nicht mehr installieren...ubuntu läuft als system im moment....hilfe!

hello, I have installed on my MacBookPro Ubuntu via Boot Camp, but bootcamp has deletet that MacOS partion and created just one new and installed ubuntu. Now I can not install MacOS 10 from the DVD, the gray screen comes when I use the "C" key during the boot process. it starts booting... (2 Replies)
Discussion started by: ingwio
2 Replies
All times are GMT -4. The time now is 09:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy