Skip to main content

Things you need to know about cron

cron is a Linux utility which schedules a command or script on your server to run automatically at a specified time and date. 
They're most commonly used for automating system maintenance or administration. However, they are also relevant to web application development. 

Why use cron? 

Server admins have been using cron jobs for a long time.  
  • You can expire and erase cached data files in a certain interval.
  • You can auto-check your website content for broken links and have a report e-mailed to yourself regularly.
  • Can update your database from external api 
Here is a simple cron job:
1
10 * * * * /usr/bin/php /www/virtual/username/cron.php > /dev/null 2>&1
It consists of five parts:
  1. minute
  2. hour
  3. day of month
  4. month
  5. day of week

Can generate the sequence from  crontab guru,   https://crontab.guru/every-30-minutes


Running this command will launch vi (text editor) and will let you edit the contents of the crontab:
1
crontab -e

If you would just like to see the existing crontab without editing it, you can run this command:
1
crontab -l
To delete the contents of the crontab:
1
crontab -r

For more details attached the reference link  below. 

Reference : 

Comments

Popular posts from this blog

Some Handy ssh/cli Commands

On Wednesday night you logged in into your server through ssh. Checking is this server capable to certain applications or not. First you ask which OS is it using.  Assuming its a Linux server. Following command will show you the OS : uname - a

Git: Remove Branches after Merge

After complete your task of a branch commit and push it. Then checkout to the main(normally master branch) Suppose your branch is   branch1  Then merge it git checkout master git merge branch1 After the merge, it's safe to delete the branch: git branch -d branch1 Additionally, git will warn you (and refuse to delete the branch) if it thinks you didn't fully merge it yet. If you forcefully delete a branch (with  git branch -D ) which is not completely merged yet, you have to do some tricks to get the unmerged commits back though (see below). There are some reasons to keep a branch around though. For example, if it's a feature branch, you may want to be able to do bugfixes on that feature still inside that branch. If you also want to delete the branch on a remote host, you can do: git push origin :branch1 This will forcefully delete the branch on the remote (this will not affect already checked-out repositiories though and won't prevent anyone with...

Git Repair Permissions

Git Push Error: insufficient permission for adding an object to repository database When you try to push to a shared git remote, you get the following error:  insufficient permission for adding an object to repository database After you have identified and fixed the underlying cause (see below), you’ll want to repair the permissions: cd /path/to/repo.git chgrp -R groupname . chmod -R g+rwX . find . -type d -exec chmod g+s '{}' + Underlying Causes The error could be caused by one of the following: The repository isn’t configured to be a shared repository (see  core.sharedRepository  in  git help config ). If the output of: git config core.sharedRepository is not  group  or  true  or  1  or some mask, try running: git config core.sharedRepository group and then re-run the recursive  chmod  and  chgrp  (see “Repair Permissions” above). The operating system doesn’t interpret a setgid bit o...