LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-02-2014, 03:40 PM   #1
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Rep: Reputation: Disabled
I want to add linux command in crontab to be triggered on server reboot


Hello,

I want the following two commands to run in crontab when server reboot.
Code:
cd /root/cpulimit-1.1
sh cpu &
I set them as follow but not working:
Code:
@reboot cd /root/cpulimit-1.1
@reboot sh cpu &
Please advise

Thanks in anticipation
 
Old 05-02-2014, 04:16 PM   #2
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
Put
Code:
#!/bin/sh
/root/cpulimit-1.1/cpu
into a .sh file and
Code:
chmod 700 /path/to/file.sh
@reboot /path/to/file.sh
 
1 members found this post helpful.
Old 05-02-2014, 04:32 PM   #3
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
Code:
[root@myServer cpulimit-1.1]# cat file.sh
#!/bin/sh
/root/cpulimit-1.1/cpu

[root@myServer cpulimit-1.1]# chmod 700 /root/cpulimit-1.1/file.sh
[root@myServer cpulimit-1.1]# cd ..


[root@myServer ~]# sh /root/cpulimit-1.1/file.sh
/root/cpulimit-1.1/file.sh: line 2: /root/cpulimit-1.1/cpu: Permission denied
[root@myServer ~]# 

[root@myServer ~]# chmod 700 /root/cpulimit-1.1/cpu

[root@myServer ~]# /root/cpulimit-1.1/cpu
/root/cpulimit-1.1/cpu: line 1: ./cpulimit: No such file or directory
/root/cpulimit-1.1/cpu: line 2: ./cpulimit: No such file or directory
Please advise

Last edited by Raakh5; 05-02-2014 at 04:37 PM.
 
Old 05-02-2014, 04:41 PM   #4
Raakh5
Member
 
Registered: Mar 2012
Posts: 167

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Raakh5 View Post
Code:
[root@myServer ~]# /root/cpulimit-1.1/cpu
/root/cpulimit-1.1/cpu: line 1: ./cpulimit: No such file or directory
/root/cpulimit-1.1/cpu: line 2: ./cpulimit: No such file or directory
I have provided full path to /path/to/cpulimit instead of ./cpulimit and its starting working.

Thanks from the bottom of my heart
 
Old 05-03-2014, 10:18 AM   #5
Habitual
LQ Addict
 
Registered: Jan 2011
Location: Youngstown, Ohio
Distribution: LM17.1/Xfce4.11.8
Posts: 7,159
Blog Entries: 10

Rep: Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968Reputation: 1968
You are Very Welcome.
 
  


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
[SOLVED] Problem with crontab:: command not executed properly via crontab Ankush Seth Linux - Newbie 11 11-11-2013 07:25 AM
Inquiry:How to add a command to my Linux server? hadimotamedi Linux - Newbie 11 11-10-2009 01:47 AM
Inquiry:How to make crontab job permanent even after server reboot? hadimotamedi Linux - Newbie 2 10-27-2009 04:53 PM
How to add a crontab job in Debian Linux LotharIrausquin Linux - Distributions 2 11-25-2008 07:09 AM
Personal crontab does not run after reboot of RHEL5 server prevere Linux - Newbie 2 05-20-2008 12:02 PM


All times are GMT -5. The time now is 12:25 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration