Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

launchd StartCalendarInterval ne se lance qu'une fois

6 réponses
Avatar
unbewusst.sein
bon j'ai un premier "LaunchAgents" org.ytho.daily dans mon folder
"/Users/yt/Library/LaunchAgents" qui marche comme je le souhaite

je voudrais avoir un autre daily mais avec les privilèges admin afin de
faire un synchro avec les bonnes perms.

donc j'ai repris le fichier plist précédent en le renomant
"org.ytho.admin.daily.plist", il a pour contenu d'essai :

~/Desktop%> cat /Library/LaunchAgents/org.ytho.admin.daily.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GroupName</key>
<string>admin</string>
<key>Label</key>
<string>org.ytho.admin.daily</string>
<key>LowPriorityIO</key>
<true/>
<key>Program</key>
<string>/Users/yt/bin/daily_admin</string>
<key>ProgramArguments</key>
<array>
<string>daily_admin</string>
</array>
<key>ServiceDescription</key>
<string>launch daily task under admin privileges</string>
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>15</integer>
</dict>
<key>UserName</key>
<string>yt</string>
</dict>
</plist>

et bien sûr je l'ao placé dans /Library/LaunchAgents avec ce que
j'espère être les bonnes perms :

~/Desktop%> ls -al /Library/LaunchAgents/org.ytho.admin.daily.plist
-rwxrwxr-- 1 yt admin 705 Sep 30 14:52
/Library/LaunchAgents/org.ytho.admin.daily.plist

le contenu de mon script zsh est "tout bête" :
#!/usr/bin/env zsh -w

# ~/bin/daily_admin

# for tests

DIR=/Users/yt/Desktop/
NOW=`date +'%y/%m/%d/%H_%M_%S'`
FILE="${DIR}/${NOW}"
mkdir -p "${FILE}"
exit 0


il ne fait donc que produire, pour test, une hiérarchie de fichiers sur
le Bureau.

après avoir loadé cette plist j'obtiens une hiérarchie sur le Bureu mais
une seul fois après, si j'attends + de 15 mn, rien ne s'est passé de +

je ne vois pas où est le problème...
--
Une Bévue

6 réponses

Avatar
unbewusst.sein
Une Bévue wrote:

il ne fait donc que produire, pour test, une hiérarchie de fichiers sur
le Bureau.

après avoir loadé cette plist j'obtiens une hiérarchie sur le Bureu mais
une seul fois après, si j'attends + de 15 mn, rien ne s'est passé de +


bon j'ai été trop rapide à poster, en fait le script est lancé toutes
les heures + 15mn... :

~/Desktop%> ls -al 07/09/30
drwxr-xr-x 2 yt admin 68 Sep 30 16:15 16_15_03
drwxr-xr-x 2 yt admin 68 Sep 30 17:15 17_15_01
drwxr-xr-x 2 yt admin 68 Sep 30 18:15 18_14_59
drwxr-xr-x 2 yt admin 68 Sep 30 19:15 19_15_01
drwxr-xr-x 2 yt admin 68 Sep 30 20:15 20_15_01
drwxr-xr-x 2 yt admin 68 Sep 30 21:15 21_15_01
drwxr-xr-x 2 yt admin 68 Sep 30 22:14 22_14_59
drwxr-xr-x 2 yt admin 68 Sep 30 22:15 22_15_00
drwxr-xr-x 2 yt admin 68 Sep 30 23:15 23_15_00

donc ça veut dire que :
<key>StartCalendarInterval</key>
<dict>
<key>Minute</key>
<integer>15</integer>
</dict>

sous entend un :
<key>Hour</key>
<integer>1</integer>

ou que je devrais mettre un
<key>Hour</key>
<integer>*</integer>

comment dans l'équivalent cton ???



apparemment il faut mettre "StartInterval" et non pas "StartCalendar
interval...
--
Une Bévue

Avatar
laurent.pertois
Une Bévue wrote:

apparemment il faut mettre "StartInterval" et non pas "StartCalendar
interval...


Tu devrais arrêter de t'embêter à les faire à la main et utiliser Lingon
(<http://lingon.sf.net/>). Voici ce qu'il met pour un script exécuté à
intervalles réguliers :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>13</string>
<key>ProgramArguments</key>
<array>
<string>say</string>
<string>hello</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>900</integer>
</dict>
</plist>


Le StartInterval est en secondes.

--
Politically Correct Unix - UTILITIES
The "touch" command has been removed from the standard distribution due
to its inappropriate use by high-level managers.

Avatar
unbewusst.sein
Laurent Pertois wrote:


Tu devrais arrêter de t'embêter à les faire à la main et utiliser Lingon
(<http://lingon.sf.net/>). Voici ce qu'il met pour un script exécuté à
intervalles réguliers :
[...]


j'avais utilisé "Launchd Editor.app" docum pas très explicite...

j'essaie ton say hello asap, merci !



--
Une Bévue

Avatar
unbewusst.sein
Laurent Pertois wrote:

Le StartInterval est en secondes.


OK, ça ça marche super...

MAIS pour ma synchro je veux un intervale de 86400 secondes (24 H) et la
nuit, disons à 4H du matin là, je suppose que ce n'est pas startinterval
mais calendarinterval ???


je me suis fait un admin daily qui roule sous root:admin, marche bien en
start interval, il me crée bien, pour test des fichiers :

~/Desktop%> ls -al 07/10/01
drwxr-xr-x 2 root admin 68 Oct 1 11:06 11_06_55
drwxr-xr-x 2 root admin 68 Oct 1 11:11 11_11_55
drwxr-xr-x 2 root admin 68 Oct 1 11:16 11_16_55
drwxr-xr-x 2 root admin 68 Oct 1 11:21 11_21_55

donc mon script de test "/Users/yt/bin/daily_admin" tourne bien sous
root:admin et toutes les 5 mn.

il me reste à le mettre tous les jours vers 4H du mat'

mais comment ? le lancer la première fois à 4H du mat' avec un interval
de 86400 secondes ?

--
Une Bévue

Avatar
laurent.pertois
Une Bévue wrote:

MAIS pour ma synchro je veux un intervale de 86400 secondes (24 H) et la
nuit, disons à 4H du matin là, je suppose que ce n'est pas startinterval
mais calendarinterval ???


Ben dans ce cas tu fais une tâche programmée à heure fixe :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>Test</string>
<key>ProgramArguments</key>
<array>
<string>say</string>
<string>hello</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>4</integer>
</dict>
</dict>
</plist>


Essaie Lingon, vraiment, je me répète, mais il a un assistant de
création de fichiers "launchd" qui te pose quelques questions et fait ce
qu'il faut derrière.

--
Politically Correct Unix - UTILITIES
The "touch" command has been removed from the standard distribution due
to its inappropriate use by high-level managers.

Avatar
unbewusst.sein
Laurent Pertois wrote:

Ben dans ce cas tu fais une tâche programmée à heure fixe :


Oui, c'est ce que j'ai fait "in-between" en testant à 12 H, ça roule...

Essaie Lingon, vraiment, je me répète, mais il a un assistant de
création de fichiers "launchd" qui te pose quelques questions et fait ce
qu'il faut derrière.


OK.
--
Une Bévue