LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   linux crontab error(command not found) (https://www.linuxquestions.org/questions/linux-newbie-8/linux-crontab-error-command-not-found-814409/)

mech123 06-15-2010 11:28 PM

linux crontab error(command not found)
 
i am scheduling a command for a specific time every day.
Linux crontab format which i am using :- MIN HOUR DOM MON DOW CMD
30 08 10 06 * /home/mach/script.sh

please tell me some presetting is required

EricTRA 06-15-2010 11:45 PM

Hello,

Does the command run from the console? Are you running the command as a normal user or as root? If as user does that user have the permissions to execute every command in the script? What's showing in your log files in regards to the command? What's the script supposed to do? Can you post the contents of your script and output of
Code:

ls -al <path/to/yourscript>
Kind regards,

Eric

subho.d 06-16-2010 12:29 AM

hi
Run the commend
Quote:

service crond restart
crontab -l

mech123 06-16-2010 12:55 AM

@EricTRA :
I am running command from console as a normal user.
command :-23 11 17 06 sed -f removeblankspace.sed demofile3

cat removeblanksapce.sed contents :
/^$/d
s/ */ /g

If i run this command(sed -f removeblankspace.sed demofile3) independently then this is executing successfully.

Output of ls -al command is :
-rw-rw-r-- 1 mach mach 16 Jun 16 11:10 remblasp.sed


@subho.d :-
service crond restart
bash: service: command not found

crontab -l :
no crontab for mach

EricTRA 06-16-2010 01:01 AM

Hello,

Try putting sudo in front of your command:
Code:

sudo <yourcommand>
Since you're running the command as a normal user, might be permission issue. When using sudo the system will prompt you for your user password and after typing that (doesn't echo so you're blind) should run (if your user is in the sudoers list.

Post output when you ran the command with sudo.

Kind regards,

Eric

subho.d 06-16-2010 01:01 AM

Ok
run
Quote:

whereis crontab
Then run the commend as per output ...

subho.d 06-16-2010 01:03 AM

u have the root acces ?

EricTRA 06-16-2010 01:10 AM

Hi,

Just noticed something, make the script executable:
Code:

chmod +x remblasp.sed
and since the output of
Code:

crontab -l
showed that there's no crontab for your user, in which crontab did you put it, root's?

Kind regards,

Eric

chrism01 06-16-2010 01:10 AM

cron has a minimal default PATH setting; always provide the exact absolute path to all cmds and files used.

EricTRA 06-16-2010 01:19 AM

Hi,

Didn't even think of that one chrism01, thanks for pointing it out.

Kind regards,

Eric

mech123 06-16-2010 03:45 AM

thanks
i executed my all commands at scheduled time successfully.

But service crond restart gives me
bash: service: command not found

EricTRA 06-16-2010 04:58 AM

Hello,

Which Linux distro are you using? Debian, CentOS, RedHat?

Kind regards,

Eric

mech123 06-16-2010 05:10 AM

Rhel5

EricTRA 06-16-2010 05:23 AM

Hi,

I assume you're running that restart command as normal user so can you try putting sudo in front of it?
Code:

sudo service crond restart
Kind regards,

Eric


All times are GMT -5. The time now is 12:55 AM.