Step1: Login to cPanle
Step2: Find "Cron Jobs" link and click.
Step3: Set time and command
Note: Command should be like bellow to execute a php script to send email.
/usr/bin/php -q /home/fictions/public_html/send_mail.php
If you want to execute an URL not file then command should be like bellow.
wget http://fictionsoft.com/demo/amazonapp/productRanks/send_mail
If you don't want to send an cron job operation status email(Given cron jobs form) then command should be like bellow.
wget http://fictionsoft.com/demo/amazonapp/productRanks/send_mail >/dev/null 2>&1
=====
find /home/angelasmaneattra/public_html/var/session/ -mtime +1 -exec rm -rf '{}' \;
find /home/angelasmaneattra/public_html/var/session/ -mtime +1 -exec rm {} \;
/usr/bin/find
Showing posts with label Commands. Show all posts
Showing posts with label Commands. Show all posts
Most Useful command snippet
http://www.linfo.org/command_index.html
mkdir - make directory
rm - how to remove full directory
cat - cat stands for "catenate." It reads data from files, and outputs their contents.
touch - The touch command updates the access and modification times of each FILE to the current system time. If you specify a FILE that does not already exist, touch creates an empty file with that name
ls - Lists the contents of a directory. If you want to see the the permission of a file you can use
tar -
gzip -
gunzip -
tail - tail -f app/tmp/logs/error.log
mkdir - make directory
rm - how to remove full directory
cat - cat stands for "catenate." It reads data from files, and outputs their contents.
touch - The touch command updates the access and modification times of each FILE to the current system time. If you specify a FILE that does not already exist, touch creates an empty file with that name
ls - Lists the contents of a directory. If you want to see the the permission of a file you can use
ls -l /path/to/file
command.tar -
gzip -
gunzip -
tail - tail -f app/tmp/logs/error.log
grep '|' app/etc/applied.patches.list click
Find files modified in the last 10 days: find wp-content -type f -mtime -10
mv - move command
mv - user to move a file to another folder or directory.
mv
How to move all files including hidden files into parent directory via *
mv
/path/subfolder /path
How to move all files including hidden files into parent directory via *
mv /path/subfolder/* /path/ # your current approach
mv /path/subfolder/.* /path/ # this one for hidden files
Or all together
mv /path/subfolder/{.,}* /path/
Which expands to:
mv /path/subfolder/* /path/subfolder/.* /path/
(example: echo a{.,}b expands to a.b ab)
cp - copy command
cp is used to copy files and directories
$ cp [options] source dest
cp /c/users/iman/Desktop/images/*.jpg /e/test/
copy a directory / copy the images folder into test folder
cp - r /c/users/iman/Desktop/images/ /e/test/
cp command main options:
option description
cp -a archive files
cp -f force copy by removing the destination file if needed
cp -i interactive - ask before overwrite
cp -l link files instead of copy
cp -L follow symbolic links
cp -n no file overwrite
cp -R recursive copy (including hidden files)
cp -u update - copy when source is newer than dest
cp -v verbose - print informative messages
scp
scp stands for "secure copy." “copy source_file_name”
into “destination_folder” at “destination_host” using “username account”.
scp source_file_name username@destination_host:destination_folder
$ scp source_file_path destination_file_path
Depending on the host, the file path should include the full host address, port number, username and password along with the directory path.
So if you are "sending" file from your local machine to a remote machine (uploading) the syntax would look like this
$ scp ~/my_local_file.txt user@remote_host.com:/some/remote/directory
When copying file from remote host to local host (downloading), its looks just the reverse
$ scp user@remote_host.com:/some/remote/directory ~/my_local_file.txt # just download the file $ scp user@192.168.1.3:/some/path/file.txt .
Transfer multiple files
Multiple files can be specified separated by a space like this
$ scp foo.txt bar.txt username@remotehost:/path/directory/
Copy entire directory (recursively)
To copy an entire directory from one host to another use the r switch and specify the directory
$ scp -v -r ~/Downloads root@192.168.1.3:/root/Downloads
Copy files across 2 remote hosts
Scp can copy files from 1 remote host to another remote host as well.
$ scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
$ cp [options] source dest
cp /c/users/iman/Desktop/images/*.jpg /e/test/
copy a directory / copy the images folder into test folder
cp - r /c/users/iman/Desktop/images/ /e/test/
cp command main options:
option description
cp -a archive files
cp -f force copy by removing the destination file if needed
cp -i interactive - ask before overwrite
cp -l link files instead of copy
cp -L follow symbolic links
cp -n no file overwrite
cp -R recursive copy (including hidden files)
cp -u update - copy when source is newer than dest
cp -v verbose - print informative messages
scp
scp stands for "secure copy." “copy source_file_name”
into “destination_folder” at “destination_host” using “username account”.
scp source_file_name username@destination_host:destination_folder
$ scp source_file_path destination_file_path
Depending on the host, the file path should include the full host address, port number, username and password along with the directory path.
So if you are "sending" file from your local machine to a remote machine (uploading) the syntax would look like this
$ scp ~/my_local_file.txt user@remote_host.com:/some/remote/directory
When copying file from remote host to local host (downloading), its looks just the reverse
$ scp user@remote_host.com:/some/remote/directory ~/my_local_file.txt # just download the file $ scp user@192.168.1.3:/some/path/file.txt .
Transfer multiple files
Multiple files can be specified separated by a space like this
$ scp foo.txt bar.txt username@remotehost:/path/directory/
Copy entire directory (recursively)
To copy an entire directory from one host to another use the r switch and specify the directory
$ scp -v -r ~/Downloads root@192.168.1.3:/root/Downloads
Copy files across 2 remote hosts
Scp can copy files from 1 remote host to another remote host as well.
$ scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
unzip command - decompress file
Unzip into current directory:
unzip filename.zip
Unzip into different directory
unzip file.zip -d somedir
Linux important commands
ls - is used for viewing files, folders and directories.
cd/arora/applications
As you might have noted, the path name listed lists in reverse order. Logically cd/arora/applications reads change to the arora directory which is stored in the applications directory. All Linux commands follow a logical path.
mv - user to move a file to another folder or directory. mv arora/applications/majorapps /arora/applications/minorapps
mkdir - user to make a new directory. mkdir testdirectory
rmdir - user to remove an existing directory. rmdir testdirectory
touch -
The touch command - a.k.a. the make file command - allows users to make files using the Linux CLI. Just as the mkdir command makes directories, the touch command makes files. Just as you would make a .doc or a .txt using a PC desktop, the touch command makes empty files. An example of the touch command: touch testfile.txt
The aforementioned command removed testfile.txt. Interestingly, whereas the rmdir command will only delete an empty directory, the rm command will remove both files and directories with files in it. This said, the rm command carries more weight than the rmdir command and should be used with more specificity.
recursive delete
rm -r dirName
The example below shows all files in the system that contains the word crontab in it.
you can either connect as
cp /c/users/iman/Desktop/images/*.jpg /e/test/
copy a directory / copy the images folder into test folder
cp - r /c/users/iman/Desktop/images/ /e/test/
cp command main options:
So if you are "sending" file from your local machine to a remote machine (uploading) the syntax would look like this
$ scp ~/my_local_file.txt user@remote_host.com:/some/remote/directory
When copying file from remote host to local host (downloading), its looks just the reverse
$ scp user@remote_host.com:/some/remote/directory ~/my_local_file.txt # just download the file $ scp user@192.168.1.3:/some/path/file.txt .
Transfer multiple files
Multiple files can be specified separated by a space like this
If no options are specified, chmod modifies the permissions of the file specified by filename to the permissions specified by permissions.
The following command creates a tar archive using a directory, adding all files in it and sub directories as well.
In order to compress, use the "z" or "j" option for gzip or bzip respectively.
Example: man cp
This will open up the "cp" manual document for us in the shell. The manual shows us the parameters available for the commands.
note: To close the manual simply press "Q".
Now, just type whatever you want in the file:
CTRL-D to save and exit
create an empty file:
You can view multiple files at the same time. Following example prints the content of file1 followed by file2 to stdout.
cd
The cd command - change directory - will allow the user to change between file directories. As the name command name suggest, you would use the cd command to circulate between two different directories. For example, if you wanted to change from the home directory to the Arora directory, you would input the following command:cd/arora/applications
As you might have noted, the path name listed lists in reverse order. Logically cd/arora/applications reads change to the arora directory which is stored in the applications directory. All Linux commands follow a logical path.
mv - user to move a file to another folder or directory. mv arora/applications/majorapps /arora/applications/minorapps
mkdir - user to make a new directory. mkdir testdirectory
rmdir - user to remove an existing directory. rmdir testdirectory
touch -
The touch command - a.k.a. the make file command - allows users to make files using the Linux CLI. Just as the mkdir command makes directories, the touch command makes files. Just as you would make a .doc or a .txt using a PC desktop, the touch command makes empty files. An example of the touch command: touch testfile.txt
rm -
The rm command - remove - like the rmdir command is meant to remove files from your Linux OS. Whereas the rmdir command will remove directories and files held within, the rm command will delete created files. An example of the rm command: rm testfile.txtThe aforementioned command removed testfile.txt. Interestingly, whereas the rmdir command will only delete an empty directory, the rm command will remove both files and directories with files in it. This said, the rm command carries more weight than the rmdir command and should be used with more specificity.
recursive delete
rm -r dirName
locate
Using locate command you can quickly search for the location of a specific file (or group of files). Locate command uses the database created by updatedb.The example below shows all files in the system that contains the word crontab in it.
$ locate crontab /etc/anacrontab /etc/crontab /usr/bin/crontab /usr/share/doc/cron/examples/crontab2english.pl.gz /usr/share/man/man1/crontab.1.gz /usr/share/man/man5/anacrontab.5.gz /usr/share/man/man5/crontab.5.gz /usr/share/vim/vim72/syntax/crontab.vim
Clear
clear clears your screen if this is possible. It looks in the environment for the terminal type and then in the terminfo database to figure out how to clear the screen.clear ignores any command-line parameters that may be present.
pwd - Prints the absolute path of the current working directory.
ssh - OpenSSH SSH client (remote login program)
ssh (SSH client) is a program for logging into a remote machine and for executing commands on a remote machine. It is intended to replace rlogin and rsh, and provide secure encrypted communications between two untrusted hosts over an insecure network. X11 connections and arbitrary TCP ports can also be forwarded over the secure channel.ssh connects and logs into the specified hostname (with optional user name). The user must prove his/her identity to the remote machine using one of several methods depending on the protocol version used (see below).
you can either connect as
ssh remote_host
or
ssh remote_username@remote_host
$ cp [options] source destcp is used to copy files and directories
cp /c/users/iman/Desktop/images/*.jpg /e/test/
copy a directory / copy the images folder into test folder
cp - r /c/users/iman/Desktop/images/ /e/test/
cp command main options:
option | description |
---|---|
cp -a | archive files |
cp -f | force copy by removing the destination file if needed |
cp -i | interactive - ask before overwrite |
cp -l | link files instead of copy |
cp -L | follow symbolic links |
cp -n | no file overwrite |
cp -R | recursive copy (including hidden files) |
cp -u | update - copy when source is newer than dest |
cp -v | verbose - print informative messages |
scp
scp stands for "secure copy." “copy source_file_name”
into “destination_folder” at “destination_host” using “username account”.
scp source_file_name username@destination_host:destination_folder
$ scp source_file_path destination_file_path
Depending on the host, the file path should include the full host address, port number, username and password along with the directory path.
So if you are "sending" file from your local machine to a remote machine (uploading) the syntax would look like this
$ scp ~/my_local_file.txt user@remote_host.com:/some/remote/directory
When copying file from remote host to local host (downloading), its looks just the reverse
$ scp user@remote_host.com:/some/remote/directory ~/my_local_file.txt # just download the file $ scp user@192.168.1.3:/some/path/file.txt .
Transfer multiple files
Multiple files can be specified separated by a space like this
$ scp foo.txt bar.txt username@remotehost:/path/directory/
Copy entire directory (recursively)
To copy an entire directory from one host to another use the r switch and specify the directory$ scp -v -r ~/Downloads root@192.168.1.3:/root/Downloads
Copy files across 2 remote hosts Scp can copy files from 1 remote host to another remote host as well. $ scp user1@remotehost1:/some/remote/dir/foobar.txt user2@remotehost2:/some/remote/dir/
chmod
chmod is used to change the permissions of files or directories.
In general, chmod commands take the form:
chmod options permissions filename
If no options are specified, chmod modifies the permissions of the file specified by filename to the permissions specified by permissions.
- 4 stands for "read",
- 2 stands for "write",
- 1 stands for "execute", and
- 0 stands for "no permission."
$ chmod -R 755 directory-name/
http://www.computerhope.com/unix/uchmod.htm
http://www.thegeekstuff.com/2010/06/chmod-command-examples/
tar
Create a tar/tar.gz archive
Now that we have learnt how to extract existing tar archives, its time to start creating new ones. The tar command can be told to put selected files in an archive or an entire directory. Here are some examples.The following command creates a tar archive using a directory, adding all files in it and sub directories as well.
$ tar -cvf abc.tar ./new/
./new/
./new/cde.txt
./new/abc.txt
The above example does not create a
compressed archive. Just a plain archive, that puts multiple files together
without any real compression. In order to compress, use the "z" or "j" option for gzip or bzip respectively.
$ tar -cvzf abc.tar.gz ./new/
Extract a tar.gz archive
$ tar -xvzf tarfile.tar.gz
$ tar -xvzf /path/to/yourfile.tgz
x - Extract files
v - verbose, print the file names as they are extracted one by one
z - The file is a "gzipped" file
f - Use the following tar archive for the operation
Extract tar.bz2/bzip archives
Files with extension bz2 are compressed with the bzip algorithm and tar command
can deal with them as well. Use the j option instead of the z option.
$ tar -xvjf archivefile.tar.bz2
Extract files to a specific directory or path
To extract out the files to a specific directory, specify the path using the "-C" option. Note that its a capital C
$ tar -xvzf abc.tar.gz -C /opt/folder/
However first make sure that the destination directory exists,
since tar is not going to create the directory for you and will fail if it does not exist.
Backup with tar
A real scenario is to backup
directories at regular intervals. The tar command can be scheduled to take such
backups via cron. Here is an example -
$ tar -cvz -f archive-$(date
+%Y%m%d).tar.gz ./new/
Run the above command via cron and it
would keep creating backup files with names like -
'archive-20150218.tar.gz'.
Ofcourse make sure that the disk
space is not overflown with larger and larger archives.
man
The man command shows the users the "manual" of the command. In some situation you might need to get more information about the command you are using. The man command shows you this information about the command.Example: man cp
This will open up the "cp" manual document for us in the shell. The manual shows us the parameters available for the commands.
note: To close the manual simply press "Q".
shutdown
Shutdown the system and turn the power off immediately.# shutdown -h nowShutdown the system after 10 minutes.
# shutdown -h +10Reboot the system using shutdown command.
# shutdown -r nowForce the filesystem check during reboot.
# shutdown -Fr now
history
The “history”
command stands for History (Event) Record,
it prints the history of long list of executed commands in terminal.
cat
Create a file using cat
$ cat > myfile.txt
Now, just type whatever you want in the file:
Hello World!
CTRL-D to save and exit
create an empty file:
touch myfile.txt
You can view multiple files at the same time. Following example prints the content of file1 followed by file2 to stdout.
$ cat file1 file2
ssh display
$ cat ~/.ssh/id_rsa.pub
Subscribe to:
Posts (Atom)