issue210:c_c
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
| issue210:c_c [2024/10/28 07:03] – d52fr | issue210:c_c [2024/10/29 17:37] (Version actuelle) – andre_domenech | ||
|---|---|---|---|
| Ligne 6: | Ligne 6: | ||
| Cron runs only when the computer does, so if you close your laptop and it hibernates or sleeps, cron does not run. You may have noticed that the files inside *my cron.daily folder, in the image, is green. That is because if the files in there are not executable, they do not run. (Sounds logical, but you would be surprised at how often it bowled someone over).** | Cron runs only when the computer does, so if you close your laptop and it hibernates or sleeps, cron does not run. You may have noticed that the files inside *my cron.daily folder, in the image, is green. That is because if the files in there are not executable, they do not run. (Sounds logical, but you would be surprised at how often it bowled someone over).** | ||
| + | |||
| + | Désolé les gars, j'ai passé le mois à l' | ||
| + | |||
| + | Cron | ||
| + | |||
| + | Si vous avez déjà tapé « man cron », vous avez peut-être été bombardé d' | ||
| + | |||
| + | Cron ne s' | ||
| **We can do a quick example by making a script, and putting it in one of the folders, and see if it runs. Just keep in mind that this method does not give one fine-grained control. By this I mean, the file I put in the daily folder will run every day, but I cannot tell it to run at, say, ten to four in the morning. For that we use another method. | **We can do a quick example by making a script, and putting it in one of the folders, and see if it runs. Just keep in mind that this method does not give one fine-grained control. By this I mean, the file I put in the daily folder will run every day, but I cannot tell it to run at, say, ten to four in the morning. For that we use another method. | ||
| Ligne 18: | Ligne 26: | ||
| Save it, make it executable with chmod +x and we are ready to go. Always test your scripts first. Once you know it works, remove the folder it created and let's pop it into cron.hourly.** | Save it, make it executable with chmod +x and we are ready to go. Always test your scripts first. Once you know it works, remove the folder it created and let's pop it into cron.hourly.** | ||
| + | |||
| + | Nous pouvons faire un exemple rapide en créant un script et en le plaçant dans l'un des dossiers, et voir s'il s' | ||
| + | |||
| + | Ouvrez votre éditeur préféré et créons un simple script : | ||
| + | |||
| + | #!/bin/sh | ||
| + | |||
| + | mkdir -p ~/fcm | ||
| + | cd ~/fcm | ||
| + | touch here.txt | ||
| + | |||
| + | Sauvegardez-le, | ||
| + | |||
| **Now continue to enjoy your free magazine and you can check it again in an hour. This is an easy way to run scripts, however if you take the LPIC exam, they will want to know if you can remember the minute, hour, day of month, month, day of week. In Ubuntu, it is visible in a helpful comment, but for the exam, they will not give it to you, instead wanting you to remember the order. You can use a mnemonic, like my house of dominoes mowed down, to remember it. If you have trouble visualising how the numbering works, I suggest playing online with crontab guru: https:// | **Now continue to enjoy your free magazine and you can check it again in an hour. This is an easy way to run scripts, however if you take the LPIC exam, they will want to know if you can remember the minute, hour, day of month, month, day of week. In Ubuntu, it is visible in a helpful comment, but for the exam, they will not give it to you, instead wanting you to remember the order. You can use a mnemonic, like my house of dominoes mowed down, to remember it. If you have trouble visualising how the numbering works, I suggest playing online with crontab guru: https:// | ||
| Ligne 24: | Ligne 45: | ||
| Let us use this time to do something with crontab (Cron table). Please remember that crontab is different per user. You can specify the user with the tack: -u For now, I want you to do this with your own user or a test user on your system. If your system has a file named / | Let us use this time to do something with crontab (Cron table). Please remember that crontab is different per user. You can specify the user with the tack: -u For now, I want you to do this with your own user or a test user on your system. If your system has a file named / | ||
| + | |||
| + | Maintenant, continuez à profiter de votre magazine gratuit et vous pourrez le vérifier à nouveau dans une heure. C'est un moyen facile d' | ||
| + | |||
| + | Au bas de la page, vous verrez « examples ». Je vous suggère de les regarder attentivement car je me souviens que les exemples du test étaient exactement ce que vous verrez là. | ||
| + | |||
| + | Profitons-en pour faire quelque chose avec crontab (table Cron). N' | ||
| + | |||
| **Please type crontab -l first to see if you have an existing file created. | **Please type crontab -l first to see if you have an existing file created. | ||
| Ligne 40: | Ligne 68: | ||
| There is an ‘at daemon’ running in the background, atd, that will check the job queue for jobs to run. The other thing that comes up that you need to know is that the ‘at’ command submits the job to that very queue. Other than that, it did not go into detail. You may have noticed that there is no man entry for ‘at’ in Ubuntu as it is not installed by default. (It is not difficult to install). So, if you want to know more, I’ll be pointing you to the interwebs as I have limited space in the magazine: https:// | There is an ‘at daemon’ running in the background, atd, that will check the job queue for jobs to run. The other thing that comes up that you need to know is that the ‘at’ command submits the job to that very queue. Other than that, it did not go into detail. You may have noticed that there is no man entry for ‘at’ in Ubuntu as it is not installed by default. (It is not difficult to install). So, if you want to know more, I’ll be pointing you to the interwebs as I have limited space in the magazine: https:// | ||
| + | |||
| + | Tapez d' | ||
| + | |||
| + | Le choix est libre, mais comme il s'agit d'un tutoriel pour débutants, j'opte pour nano. | ||
| + | |||
| + | Dans l' | ||
| + | |||
| + | Nous l' | ||
| + | |||
| + | Maintenant, toutes les 5 minutes, mon script s' | ||
| + | |||
| + | L' | ||
| + | |||
| + | Ce que vous devez savoir pour l' | ||
| + | |||
| + | Il y a un « démon at », atd, qui tourne en arrière-plan et qui vérifie la file d' | ||
| + | |||
| **Because things change in exams, and the last time I gave a class in this, it was two exam versions ago, I’d just like to point out that ‘at’ does not only consist of ‘at’ and its daemon, there are other files involved, namely: | **Because things change in exams, and the last time I gave a class in this, it was two exam versions ago, I’d just like to point out that ‘at’ does not only consist of ‘at’ and its daemon, there are other files involved, namely: | ||
| Ligne 56: | Ligne 101: | ||
| As always, if I made a mistake: misc@fullcirclemagazine.org** | As always, if I made a mistake: misc@fullcirclemagazine.org** | ||
| + | |||
| + | Parce que les choses changent dans les examens et que la dernière fois que j'ai donné un cours sur ce sujet, c' | ||
| + | /usr/bin/at | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | |||
| + | Puisque le cours LPIC est agnostique en matière de distro, je vous suggère de classer ces éléments dans un endroit où vous pourrez vous en souvenir si nécessaire. | ||
| + | |||
| + | Le fait de lancer une commande ou un script à un moment donné n'est pas difficile, mais le guide de l' | ||
| + | |||
| + | L'un de mes devoirs préférés consistait à demander aux étudiants de jouer le fichier wave d'un gong toutes les heures via cron. Je vous suggère d' | ||
| + | |||
| + | Comme toujours, si j'ai fait une erreur : misc@fullcirclemagazine.org | ||
| + | |||
issue210/c_c.1730095439.txt.gz · Dernière modification : 2024/10/28 07:03 de d52fr
