Good afternoon, how do I run a script on CentOS 6.5?
I'm running on
/etc/rc.local
/etc/rc.d/rc.local
and is not loading commands:
sh /etc/init.d/script
The command works outside the script.
Good afternoon, how do I run a script on CentOS 6.5?
I'm running on
/etc/rc.local
/etc/rc.d/rc.local
and is not loading commands:
sh /etc/init.d/script
The command works outside the script.
You have the commands set in the script file
If this is it, try to give the file full permission and make it executable.
chmod +777 /etc/init.d/script
chmod + x /etc/init.d/script
/etc/rc.local
or /etc/rc.d/rc.local
are no longer executed due to changes in CentOS.
To continue using them, you need to keep /etc/rc.d/rc.local
as executable:
chmod +x /etc/rc.d/rc.local
Debug
To debug the problem, it would be a good idea to redirect the output of the script ( /etc/init.d/script > /var/log/seu_log
) to make sure the script is running or not.
Example:
# touch > /root/meu_script.sh
# touch > /var/log/meu_log && chmod 777 /var/log/meu_log
Save the content:
#!/bin/bash
echo 'Nossa! Estou vivo!'
Give permission:
chmod +x /root/meu_script.sh
And schedule your boot run to:
/etc/init.d/script > /var/log/meu_log
After booting, make sure the /var/log/meu_log
file is empty or written. If it is empty, obviously the script did not run at boot.