Skip to content

Wie man cron job ubuntu code beispiel erstellen

Wenn Sie einen Fehler in Ihrem Code oder Ihrer Arbeit finden, denken Sie daran, immer in einer Testumgebung zu testen, bevor Sie den Code der endgültigen Arbeit hinzufügen.

Beispiel: cron job in ubuntu einrichten

Setting Up a Website Backup through Cron :-
===========================================
Step 1: Update your server. As a best practice, we will update and upgrade
our server with the following command.
	apt-get update &&apt-get upgrade

Step 2: Verify if the cron package is installed.
	dpkg -l cron

	a) Our example output let’s us know that the cron package is installed, along 
	with its version:

||/ Name Version Architecture Description
+++-=========================-=================-=================-========================================================
ii cron3.0pl1-128ubuntu2 amd64 process scheduling daemon

	b) Install cron package if necessary.
		sudoapt-getinstallcron

	c) Ensure that the cronservice is running with the following command:
		systemctl status cron

Example Output:
----------------
* cron.service - Regular background program processing daemon
Loaded: loaded (/lib/systemd/system/cron.service; enabled; vendor preset:enabled)
Active: active (running) since Sat 2018-10-27 02:53:20 EDT;5 days ago

Step 3: Configure the cron job. When you are logged in as your user, you are
creating a cron job under that user. Creating a cronjobs owner is helpful
when to know who is in charge of the cron as well as how to alter the cron 
job in the future.
	crontab -e

Step 4: The system asks which editor you’d like to use; this tutorial is using option 2(vim.basic).

[email protected]:~$ crontab -e
no crontabfor tom - using an empty one
Select an editor. To change later, run 'select-editor'.1. /bin/ed
2. /usr/bin/vim.basic
3. /usr/bin/vim.tiny
Choose 1-3 []: 2

Step 5: In this file, you’ll see # signs followed by the direction on how to#use the file. Allow us a minute to explain the syntax needed to create a cron#task.# Example of job definition:# .---------------- minute (0 - 59)# | .------------- hour (0 - 23)# | | .---------- day of month (1 - 31)# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat# | | | | |# * * * * * user-name command to be executed

Kommentare und Bewertungen



Nutzen Sie unsere Suchmaschine

Suche
Generic filters

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht.