Running sudo without entering the password
In my experience, If you want to run a command with sudo privileges but don't want to bother entering the password, visudo is the best way to go.
For example you want to run this command when log-in as user youruser (a sudoer):
sudo php /path/to/your/script.php some_params
Note that the param may be different.
1. First, running this as root:
# visudo
2. Then add the following line:
youruser ALL=(root) NOPASSWD: /usr/bin/php /path/to/your/script.php *
3. Save and exit the editor
For example you want to run this command when log-in as user youruser (a sudoer):
sudo php /path/to/your/script.php some_params
Note that the param may be different.
1. First, running this as root:
# visudo
2. Then add the following line:
youruser ALL=(root) NOPASSWD: /usr/bin/php /path/to/your/script.php *
3. Save and exit the editor