LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   I want to add linux command in crontab to be triggered on server reboot (https://www.linuxquestions.org/questions/linux-newbie-8/i-want-to-add-linux-command-in-crontab-to-be-triggered-on-server-reboot-4175503730/)

Raakh5 05-02-2014 02:40 PM

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

Habitual 05-02-2014 03:16 PM

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

Raakh5 05-02-2014 03:32 PM

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

Raakh5 05-02-2014 03:41 PM

Quote:

Originally Posted by Raakh5 (Post 5163506)
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

Habitual 05-03-2014 09:18 AM

You are Very Welcome.


All times are GMT -5. The time now is 11:17 PM.