Kategorie: Linux

Run multiple commands in one cron job

You can separate two or more commands with semicolons (;),
Semicolon (;): is used to separate multiple commands. This causes all commands to be executed without checking the exit status of previous commands.

We can separate two or more commands with a semicolon, which do not require checking the exit status of the previous command. E.g, you need to change the permissions of all files to 777, but you have to set 777 for the logs directory.

The cron command will look like this:

0 2 * * *   chmod -R 755 /var/www/myapp; chmod -R 777 /var/www/myapp/logs

Use this command, if you want to run the next command only then, when the previous one was successful (exit status 0). For example, you want to run backup.sh after successfully navigating to the / backup directory.

0 2 * * *   cd /backup && bash backup.sh

Linux

Udostępnij
Opublikowane przez
Linux

Recent posts

KeePass2 2.52 w Ubuntu 22.04

The guide below describes how to install KeePass on Ubuntu. Całość wykonamy za pomocą kilku poleceń

2 years temu

Installing Master PDF editor in Ubuntu 22.04

Master PDF Editor is a comprehensive PDF program, which includes many features. Oprócz tworzenia i edycji

2 years temu

iotop - memory monitoring

Iotop jest prostym narzędziem dla systemów Uniksowych umożliwiającym monitorowanie użycia dowolnego nośnika pamięci flash/hdd/ssd w

2 years temu

Changing the exif data of a photo in the Linux terminal

Poniższy poradnik opisuje w jaki sposób za pomocą konsoli możemy dokonać edycji danych zdjęcia exif.

2 years temu

Installing Rocket.Chat Server on Rocky Linux 8

The following guide describes how to install Rocket.Chat on Rocky Linux 8 Całość bardzo prosto zainstalujemy

2 years temu

Adobe Acrobat Reader W Ubuntu 22.04

The following guide describes the installation of Adobe Acrobat Reader in Ubuntu 22.04. We made in a few minutes…

2 years temu