Inviare file tramite bluetooth da crontab

Pubblicità

CCT92

Nuovo Utente
Messaggi
62
Reazioni
4
Punteggio
26
Ciao a tutti. Vorrei inviare dei file tramite bluetooth e per questo ho creato un crontab.
Ho il seguente crontab:
Codice:
*/1 * * * * bluetooth-sendto --device=MACADDR /home/utente/reads.txt
Non funziona, nonostante il comando
Codice:
bluetooth-sendto --device=MACADDR /home/utente/reads.txt
inviato da terminale funzioni correttamente. Da cosa può dipendere?
Sto usando Lubuntu. Il file che voglio inviare ha permessi 777.
 
Quel /1 mi sa che non serve, se metti tutti asterischi di default dovrebbe andare comunque ogni minuto.
Prova a fare uno script .sh contenente quel comando (ricordati di dargli il +x per renderlo eseguibile) e vedi se quello lo lancia.
Se non va prova a mettere in crontab un comando scemo tipo date >> ciao.txt. Se ogni minuto aggiunge la riga il problema era nello script, se non lo fa il problema è nel crontab
 
Grazie per la risposta. Ho provato anche con altri tipi di comandi e a lanciare uno script, tutto funziona ma non quello che serve a me.
 
Io abiliterei i log per vedere cosa non funziona. Ubuntu Linux check cron log file error or messages in /var/log/cron.log file

I comandi di quella guida dovrebbero andare ancora bene
Ho seguito la guida e nel log ho:
Jun 16 14:26:01 localhost CRON[2023]: (user) CMD (bluetooth-sendto --device=xx:xx:xx:xx:xx:xx /home/user/send.txt)Jun 16 14:26:01 localhost CRON[2016]: (CRON) info (No MTA installed, discarding output)

- - - Updated - - -

Chi è l'utente che lancia la cron?
dovrebbe essere user, il mio utente.
 
Uhm, io modificherei il comando in modo da mandare l'output del comando su un file di log (adesso viene scartato perché manca un MTA tipo postfix)

Codice:
*/1 * * * * bluetooth-sendto --device=MACADDR /home/utente/reads.txt >> /home/utente/logfile.txt

Poi controlli il file di testo logfile.txt
 
Uhm, io modificherei il comando in modo da mandare l'output del comando su un file di log (adesso viene scartato perché manca un MTA tipo postfix)

Codice:
*/1 * * * * bluetooth-sendto --device=MACADDR /home/utente/reads.txt >> /home/utente/logfile.txt

Poi controlli il file di testo logfile.txt
Fatto. Il file viene creato ma è vuoto.
Comunque continua a dirmi:
(CRON) info (No MTA installed, discarding output)

- - - Updated - - -

Ho aggiunto MAILTO="" all'inizio del cron, così non mi dice più "(CRON) info (No MTA installed, discarding output)", ma il file di log continua ad essere vuoto.

- - - Updated - - -

Ci sono altri modi con cui potrei inviare file tramite buetooth in automatico?
 
Ultima modifica:
Ultima prova: eseguiamo il redirect su file anche di STDERR (ovvero i possibili errori del comando)

Codice:
*/1 * * * * bluetooth-sendto --device=MACADDR /home/utente/reads.txt >> /home/utente/logfile.txt 2>&1

EDIT: il comando manuale viene lanciato sempre da utente normale o tramite sudo?
 
Ultima prova: eseguiamo il redirect su file anche di STDERR (ovvero i possibili errori del comando)

Codice:
*/1 * * * * bluetooth-sendto --device=MACADDR /home/utente/reads.txt >> /home/utente/logfile.txt 2>&1

EDIT: il comando manuale viene lanciato sempre da utente normale o tramite sudo?
Solitamente lo lancio da utente normale.
Nel file è comparso questo adesso:
error: XDG_RUNTIME_DIR not set in the environment.
Cannot open display:
 
Prova, invece che dare a crontab il comando tale e quale, a dargli uno script che lo contenga. Se c'è ancora l'errore per quella variabile, settala a mano nello script
Io ce l'ho settata così, se do env da terminale: XDG_RUNTIME_DIR=/run/user/1000

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

The lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in and if the user fully logs out the directory MUST be removed. If the user logs in more than once he should get pointed to the same directory, and it is mandatory that the directory continues to exist from his first login to his last logout on the system, and not removed in between. Files in the directory MUST not survive reboot or a full logout/login cycle.
The directory MUST be on a local file system and not shared with any other system. The directory MUST by fully-featured by the standards of the operating system. More specifically, on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions, file locking, sparse files, memory mapping, file change notifications, a reliable hard link count must be supported, and no restrictions on the file name character set should be imposed. Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.
 
Prova, invece che dare a crontab il comando tale e quale, a dargli uno script che lo contenga. Se c'è ancora l'errore per quella variabile, settala a mano nello script
Io ce l'ho settata così, se do env da terminale: XDG_RUNTIME_DIR=/run/user/1000

$XDG_RUNTIME_DIR defines the base directory relative to which user-specific non-essential runtime files and other file objects (such as sockets, named pipes, ...) should be stored. The directory MUST be owned by the user, and he MUST be the only one having read and write access to it. Its Unix access mode MUST be 0700.

The lifetime of the directory MUST be bound to the user being logged in. It MUST be created when the user first logs in and if the user fully logs out the directory MUST be removed. If the user logs in more than once he should get pointed to the same directory, and it is mandatory that the directory continues to exist from his first login to his last logout on the system, and not removed in between. Files in the directory MUST not survive reboot or a full logout/login cycle.
The directory MUST be on a local file system and not shared with any other system. The directory MUST by fully-featured by the standards of the operating system. More specifically, on Unix-like operating systems AF_UNIX sockets, symbolic links, hard links, proper permissions, file locking, sparse files, memory mapping, file change notifications, a reliable hard link count must be supported, and no restrictions on the file name character set should be imposed. Files in this directory MAY be subjected to periodic clean-up. To ensure that your files are not removed, they should have their access time timestamp modified at least once every 6 hours of monotonic time or the 'sticky' bit should be set on the file.

If $XDG_RUNTIME_DIR is not set applications should fall back to a replacement directory with similar capabilities and print a warning message. Applications should use this directory for communication and synchronization purposes and should not place larger files in it, since it might reside in runtime memory and cannot necessarily be swapped out to disk.
Quindi nello script, prima del comando, metto "$XDG_RUNTIME_DIR=/run/user/1000"?
 
Non è che, visto che quel comando fa parte del pacchetto gnome-bluetooth non c'è modo da eseguirlo senza che la sessione sia attaccata ad un server X? prova a lanciarlo da una console senza X attivo loggandoti dopo un ctrl+alt+F1/F6

- - - Updated - - -

Quindi nello script, prima del comando, metto "$XDG_RUNTIME_DIR=/run/user/1000"?
Senza $:
XDG_RUNTIME_DIR=/run/user/1000
poi per chiamarla, se mai dovrai chiamarla, userai il dollaro (es: echo $XDG_RUNTIME_DIR ti darà /run/user/1000)
 
Non è che, visto che quel comando fa parte del pacchetto gnome-bluetooth non c'è modo da eseguirlo senza che la sessione sia attaccata ad un server X? prova a lanciarlo da una console senza X attivo loggandoti dopo un ctrl+alt+F1/F6

- - - Updated - - -


Senza $:
XDG_RUNTIME_DIR=/run/user/1000
poi per chiamarla, se mai dovrai chiamarla, userai il dollaro (es: echo $XDG_RUNTIME_DIR ti darà /run/user/1000)
Ho provato a fare come mi hai detto con lo script ma continua a darmi quell'errore.
Spulciando su google ho visto ad alcuni è stato suggerito di usare pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY, potrebbe aiutarmi?
 
Pubblicità
Pubblicità
Indietro
Top