Categories
cPanel PHP Scripts SSH Web-Hosting

Execute PHP script from cron or command-line

Execute PHP script from cron or command-line

One of the method for running PHP scripts from a cron job is run the script using php from the crontab. You will need to call the php script from your crontab as given below.
To execute somescript.php every 1 hour you will need to edit and add below given line in your crontab file:
00 * * * * /usr/local/bin/php /home/someuser/somescript.php

If you are looking for command-line interpreter, then it can be done with the following command. It shows how to run a script using the PHP command-line interpreter:

/usr/local/bin/php -q /home/someuser/public_html/somescript.php
The -q option is for quiet mode, to prevent headers being displayed.

Make a note of code in your PHP script, it may only run correctly if called from a mentioned path. For example, if the script uses relative paths to include files, it will only run if it is called from the specified directory. The following command shows how to run a PHP script from a specific path:

cd /home/username/public_html/; /usr/local/bin/php -q script.php

Related: Dedicated Server, Virtual Server, Web Server Hosting

Categories
CSF Dedicated Server Firewall Security SSH VPS Hosting Web-Hosting

syslogd klogd warning in firewall

If you are getting this WARNING message, what you need to do?

Syslogd appears to be running, but not klogd which logs kernel firewall messages to syslog. You should ensure that klogd is running.

How do you enable klogd?

Fire a command:
#whereis klogd
Then simply run klogd with full path:
klogd

Related: Dedicated Servers, VPS Hosting

Categories
Dedicated Server SSH Virtual Private Server Web-Hosting

Find files greater than MB GB size in linux ssh

Find files greater than MB GB size in linux ssh. ( Such a helpful ssh command to find big, larger or largest file on server)

The following ssh command will list all the files in the system greater than 200MB.
# find / -type f -size +200M

The following ssh command will list all the files greater than 2GB.
# find / -type f -size +2G

The following ssh command will list all the files greater than 10MB from home folder only.
# find /home -type f -size +10M

Related: Linux SSH, Virtual Server

Categories
Dedicated Server Security SSH Virtual Private Server

Reboot Server from SSH

Reboot Server from SSH

How to reboot Linux server from ssh? Is it same for local and remote Linux system?

Linux has various ways to reboot a system. It is also known as halt, poweroff, shutdown, init etc.

Coming to the point, rebooting your Linux server from ssh console: The most important thing, you should be logged in as root to reboot the system. Once you are in as root, type any of the following command as per your requirement.

INSTANT REBOOT LINUX SERVER:

# reboot
OR
# /sbin/reboot
OR
# shutdown -r now
OR
# /sbin/shutdown -r now

Want to send a notification to logged in users about this reboot? Then type the following command:
# shutdown -r +2 (This will send the message to all the users that the system is going to reboot in next 2 minutes.)

Related: Linux Server, Linux VPS, Dedicated Server, Private Server

Categories
Dedicated Server Virtual Private Server Web-Hosting

Clear-ssh-command-history-in-ssh-cache-from-server

When I login to SSH and push the up arrow, the previous commands are shown. How do I clear or delete that log?

Clear the history for current login or current user.
#history -c

First find the history file for particular user.
Delete .bash_history file, will be recreated again next time.
#locate .bash_history
#rm .bash_history

It is not a best practice to totally disable the ssh command history on any dedicated server or vps server. It’s a quick reference to user’s past actions on server.