LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora
User Name
Password
Fedora This forum is for the discussion of the Fedora Project.

Notices


Reply
  Search this Thread
Old 07-24-2006, 05:54 PM   #1
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Rep: Reputation: 15
crontab execute consecutively


Hi,

I want to execute the my jobs consecutively, is that possible with crontab. After one job is finished the next starts.....and so on.




thanks
 
Old 07-24-2006, 06:06 PM   #2
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Sure, just create an entry with a command like:
Code:
15 1 * * * command1 && command2 && command3 && command4
 
Old 07-24-2006, 06:19 PM   #3
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hi matir,

thanks for your response,
does it mean, that I assign a starttime and then connect each of my tasks with &&......that's it

does it have to be in one line or can I make newlines too.....

Code:
15 1 * * * command1 && 
command2 && 
command3 && 
command4
or something like that.....due to keeping track...
 
Old 07-24-2006, 06:23 PM   #4
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Cron jobs should each appear on a single line. If you need a large number of commands, I encourage placing them in a shell script and then executing this shell script rather than placing all the commands within the cron job.
 
Old 07-24-2006, 07:20 PM   #5
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
ok, thanks

Last edited by SofNine; 07-25-2006 at 06:59 PM.
 
Old 07-25-2006, 07:00 PM   #6
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hi,

is ist possible to execute one command in the script with root and the others with the normal user?

my script is invoked usually as normal user, but I want one command to be executed as root....
 
Old 07-25-2006, 07:34 PM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You can use sudo to accomplish that.
 
Old 07-26-2006, 01:03 AM   #8
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hi,

I have tried it with sudo. They tell you that you have to make an entry in /etc/sudoer, which I have done. I have a script which executes several commands, one of them needs root privileges.
And I want the script to execute this command without asking for the password, but with the following it still asks for the password.

the entry in my sudoer file looks like:
Code:
# User privilege specification
root    ALL=(ALL) ALL
Hubert ALL=(ALL) NOPASSWD: /home/Hubert/database_update.sh
the database_update script:
Code:
#!/bin/sh
......
sudo rm -rf /usr/local/database
.......
thanks
 
Old 07-26-2006, 09:22 AM   #9
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
The part after the NOPASSWD: has to be the command to be executed as root (in this case, "rm -rf /usr/local/database").
 
Old 07-26-2006, 11:46 AM   #10
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hello matir,

I have done what you told me, but I get still permission denied. Is there anything else?

thanks
 
Old 07-26-2006, 11:50 AM   #11
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
You may need to specify a full path to rm in both sudoers and the command line itself (/bin/rm).
 
Old 07-26-2006, 01:24 PM   #12
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hi matir,

ok, I assume there is something wrong with my distribution, I get the following error:

Code:
>>> sudoers file: syntax error, line 22 <<<
sudo: parse error in /etc/sudoers near line 22
 
Old 07-26-2006, 01:37 PM   #13
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Please post the full contents of your current sudoers file.
 
Old 07-26-2006, 03:23 PM   #14
SofNine
Member
 
Registered: Apr 2006
Posts: 38

Original Poster
Rep: Reputation: 15
hi,
sudoer file:

Code:
# sudoers file.
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the sudoers man page for the details on how to write a sudoers file.
#

# Host alias specification

# User alias specification

# Cmnd alias specification

# Defaults specification

Defaults    env_reset
Defaults    env_keep = "COLORS DISPLAY HOSTNAME HISTSIZE INPUTRC KDEDIR \
                        LS_COLORS MAIL PS1 PS2 QTDIR USERNAME \
                        LANG LC_ADDRESS LC_CTYPE LC_COLLATE LC_IDENTIFICATION \
                        LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC \
                        LC_PAPER LC_TELEPHONE LC_TIME LC_ALL LANGUAGE LINGUAS \
                        _XKB_CHARSET"

# Runas alias specification

# User privilege specification
root    ALL=(ALL) ALL
Hubert ALL=(ALL) NOPASSWD: "/usr/bin/cvs -d :pserver:cvs@code.open-bio.org:/home/repository/bioperl checkout bioperl-live"

# Uncomment to allow people in group wheel to run all commands
# %wheel        ALL=(ALL)       ALL

# Same thing without a password
# %wheel        ALL=(ALL)       NOPASSWD: ALL

# Samples
# %users  ALL=/sbin/mount /cdrom,/sbin/umount /cdrom
# %users  localhost=/sbin/shutdown -h now


~
if I execute the cvs command on the command line it works just fine....of course as root
 
Old 07-26-2006, 03:32 PM   #15
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Try removing the quotes from around the command, similar to the format of other commands in the file.
 
  


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
crontab entries will not execute when not logged fatra2 Linux - Software 2 05-23-2006 02:22 AM
crontab Xris718 Linux - General 5 08-15-2005 01:03 PM
Problem when using crontab to execute a .php file doublesheep Linux - General 3 06-10-2004 08:46 AM
system-wide crontab in /etc/crontab ner Linux - General 2 11-18-2003 12:35 PM
crontab alaios Linux - General 5 05-01-2003 03:26 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Fedora

All times are GMT -5. The time now is 08:10 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