java.net member

Rechercher dans ce site

Installer Android Studio sur Fedora 25, 64bits

>> 09 June 2017


Si vous avez des  problèmes en installant Android Studio sur Linux, 64 bits (Ici Fedor 25). Commencez par installer les bibliothèques suivantes :

zlib.i686 ncurses-libs.i686 bzip2-libs.i686 mesa-libGL-devel adb compat-libstdc++-296.i686 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64

Avant




















 Après





















Read more...

Install Android Studio on Fedora 64 bits problems




I wanted to installing Android Studio on Fedora 25, 64 bits, but even after installing the needed packages mentioned in https://developer.android.com/studio/install.html, Android Studion refuses to create Android Virtual device and displays missing 32 bits libraries

$ sudo dnf install zlib.i686 ncurses-libs.i686 bzip2-libs.i686

I found some other additional packages to install by googling

$ sudo dnf install mesa-libGL-devel adb

Unfortunately the problems are always there. 



















Finally I found this answer on
https://stackoverflow.com/questions/29112107/how-to-solve-unable-to-run-mksdcard-sdk-tool-when-installing-android-studio-on
And installed the following
$ sudo dnf install compat-libstdc++-296.i686 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64

The complete list to install

zlib.i686 ncurses-libs.i686 bzip2-libs.i686 mesa-libGL-devel adb compat-libstdc++-296.i686 compat-libstdc++-33.i686 compat-libstdc++-33.x86_64

And here we are





















Enjoy!

Read more...

Anacron une action au démarrage

>> 31 May 2017


Pourquoi anacron

Si vous voulez lancer une action sur des périodes, tous les x temps, cron est votre ami.
par contre cron n'est pas capable de revenir en arrière. Si vous programmez une action à 3h du matin et vous allumez l'ordinateur à 9h, l'action ne s’exécute pas. Pour ce genre de missions il existe un programme nommé anacron, son job est de lancer une action après une période de temps, spécifié et compter à partir du démarrage de l'ordinateur.

Ajouter des action

Editez le fichier /etc/anacrontab et ajoutez des actions désirées, comme root

Note:
Il est nécessaire d'avoir les permissions nécessaires pour exécuter chaque action mentionnée.

Fichiers de cron et anacron

[root@localhost ~]# cat /etc/crontab
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# 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

[root@localhost ~]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days delay in minutes job-identifier command
1 2 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly

Ajouter une action

J'ai mis quelques commandes dans un script. Le script est exécuté comme root
Note :
J'ai modifié quelques variables dans /etc/anacrontab


[root@localhost ~]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/bash #bash est utilisé au lieu de " sh "
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/root #J'ai ajouté /root, car contenant le script
#MAILTO=root #La sortie est dirigé vers un fichier. pour le mail dé-commentez
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=0 #0 à 45 minutes est ajoutés au temps
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days delay in minutes job-identifier command
1 2 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly


#Mon action commence après 5 minutes du démarrage de l'ordinateur, tous les jours
#Le nom est au choix (ici "ka"). Le programme doit être dans PATH
1 5 ka ka_update &>> /root/log"

Anacron fichier log

Anacron ajoute un fichier (même nom que l'action) sous /var/spool/anacron, ce fichier contient la dernière date de l'exécution de l'action. Cette même date est aussi dans /var/spool/anacron/cron.daily

[root@localhost ~]# ls -ld /var/spool/anacron/*
-rw-------. 1 root root 9 May 30 19:02 /var/spool/anacron/ka

[root@localhost ~]# cat /var/spool/anacron/ka
20170530

[root@localhost ~]# date
Wed May 31 07:30:05 CEST 2017

options

Les options sont dans man anacron

Tester anacrontab

-T Teste la validité de /etc/anacrontab.

Forcer l'exécution.



-f force toutes les actions indépendamment de leurs temps
-n force toutes les actions immédiatement (avec l'option s)


-s une action est exécutée après la fin d'une autre.


-d exécute directement (pas d'arrière plan)

Fichier et dossier personnalisés


-t fichier permet d'utiliser un autre fichier, que /etc/anacrontab

-S dossier utilise le dossier donné pour stocker la date..

# anacron -S /dossier-t /etc/fichierAnacron  

Example
[root@localhost ~]# cat ka_update

#!/bin/bash

#Recherche des updates
dnf check-update &> /dev/null #pas d'affichage sur la stdout ou stderr

#exit code 0 pas d'update, 1 erreur.100 des updates disponibles
r=$? #exit code

echo "Exit code = $r"

if [[ $r -eq 100 ]]
then

dnf -y update &> /dev/null && echo "Updated $(date)"

elif [[ $r -eq 0 ]]
then echo "Pas d'updates"
elif [[ $r -eq 1 ]]
then echo "Erreur dans la commande dnf check-update"
fi

Executer the job
# anacron -d -f -n ka #exécuter l'action "ka" immédiatement
Anacron started on 2017-05-31
Will run job `ka'
Jobs will be executed sequentially
Job `ka' started
Job `ka' terminated
Normal exit (1 job run)

Cron et anacron ensemble

crond est un service lancé au démarrage, par contre anacron est un programme, ce n'est pas un service. cron lance à toutes les heures un script " 0anacron " situé sous /etc/cron.hourly

[root@localhost ~]# cd /etc/cron.hourly/
[root@localhost cron.hourly]# ls


0anacron

Le script est simple, il vérifies deux choses, si la date actuelle est dans /var/spool/anacron.daily, le script est déjà exécuté donc pas besoin de le ré-exécuter. 2ème condition, si on travaille sur un ordinateur portable en utilisant la batterie, pas la peine d'exécuter l'action.

Si les 2 conditions échouent on lance anacron pour exécuter notre action.

[root@localhost cron.hourly]# cat 0anacron
#!/bin/sh
# Check whether 0anacron was run today already
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
exit 0
fi

# Do not run jobs when on battery power
if [ `cat /sys/class/power_supply/AC/online 2>/dev/null`x = 0x ]; then
exit 0
fi
/usr/sbin/anacron -s#si les 2 conditions sont faux lance anacron

Vous avez trouvé cet article utile ! enjoy 



Read more...

Anacron how to

Why anacron



Cron can be used to run a task on regular basis. It cannot anyway run passed task. Example i want a a task to be run at 10:20, but at this time the computer was off and now it's 11:00, this means the task will wait tell next time the condition is met again.

Anacron, on the other hand, will run an action after a specified amount of time beginning when the computer is on.

Adding Tasks

To add a job add it to the file /etc/anacrontab, as root

Note:
You must have proper permission for tasks to be run.

Cron and anacron job files

[root@localhost ~]# cat /etc/crontab

SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root

# For details see man 4 crontabs

# 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


[root@localhost ~]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=45
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22

#period in days delay in minutes job-identifier command
1 2 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly


Adding a task

I will add a custom script, that will run as root.
Note here that I also customize the anacrontab file to suit my needs


[root@localhost ~]# cat /etc/anacrontab
# /etc/anacrontab: configuration file for anacron

# See anacron(8) and anacrontab(5) for details.

SHELL=/bin/bash #i want to use bash instead of sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/root #the /root folder contains my script
#MAILTO=root #I want to send output to a file. Uncomment to mail it
# the maximal random delay added to the base delay of the jobs
RANDOM_DELAY=0 #random 0 to 45 minutes added to job's time. want 0
# the jobs will be started during the following hours only
START_HOURS_RANGE=3-22 #start of action in 24h

#period in days delay in minutes job-identifier command
1 2 cron.daily nice run-parts /etc/cron.daily
7 25 cron.weekly nice run-parts /etc/cron.weekly
@monthly 45 cron.monthly nice run-parts /etc/cron.monthly



#Here I added my job to be launched 5 minutes after power on of the computer every day

#you can give it any name (here "ka"). The script or other command must be in PATH above

1 5 ka ka_update &>> /root/log"

Anacron log file

A file under the /var/spool/anacron directory, with the same name as the job. This file will contain a single line that indicates the last time the job was executed.

[root@localhost ~]# ls -ld /var/spool/anacron/*
-rw-------. 1 root root 9 May 30 19:02 /var/spool/anacron/ka

[root@localhost ~]# cat /var/spool/anacron/ka
20170530

[root@localhost ~]# date
Wed May 31 07:30:05 CEST 2017

Some very useful options

Taken simply from man anacron


Testing anacrontab

-T Anacrontab testing. Tests the /etc/anacrontab configuration file for validity. If there is an error in the file, it is shown on the standard output and Anacron returns the value of 1. Valid anacrontabs return the value of 0.

Force execution.

You can force execution

-f Forces execution of all jobs, ignoring any timestamps.
-n Runs jobs immediately and ignores the specified delays in the /etc/anacrontab file. This options implies -s.

-s Serializes execution of jobs. Anacron does not start a new job before the previous one finished.


-d Does not fork Anacron to the background. In this mode, Anacron will output informational messages to standard error, as well as to syslog. The output of any job is mailed by Anacron.

Custom files and folders

You can use some custom files instead of the standard files
-t some_anacrontab Uses the specified anacrontab, rather than the /etc/anacrontab default one.

-S spooldir Uses the specified spooldir to store timestamps in. This option is required for users who wish to run anacron themselves.

# anacron -S /mySpool -t /etc/myAnacron  

Example
[root@localhost ~]# cat ka_update

#!/bin/bash

#check first if there is an update available
dnf check-update &> /dev/null #suppress all output

#exit code 0 no update, 1 error and 100 there is updates
r=$? #this contains dnf check-update exit code

echo "Exit code = $r"

if [[ $r -eq 100 ]]
then

dnf -y update &> /dev/null && echo "Updated $(date)"

elif [[ $r -eq 0 ]]
then echo "No updates"
elif [[ $r -eq 1 ]]
then echo "Error dnf update command"
fi

Execute the job
# anacron -d -f -n ka #execute the job named "ka" immediately
Anacron started on 2017-05-31
Will run job `ka'
Jobs will be executed sequentially
Job `ka' started
Job `ka' terminated
Normal exit (1 job run)

How things really work

crond is a service that is normally enabled by default, but anacron is not a service.

cron executes hourly a script located under /etc/cron.hourly, called 0anacron

[root@localhost ~]# cd /etc/cron.hourly/
[root@localhost cron.hourly]# ls
0anacron

This script is very simple, and well documented

[root@localhost cron.hourly]# cat 0anacron
#!/bin/sh
# Check whether 0anacron was run today already
if test -r /var/spool/anacron/cron.daily; then
day=`cat /var/spool/anacron/cron.daily`
fi
if [ `date +%Y%m%d` = "$day" ]; then
exit 0
fi

# Do not run jobs when on battery power
if [ `cat /sys/class/power_supply/AC/online 2>/dev/null`x = 0x ]; then
exit 0
fi
/usr/sbin/anacron -s#when the 2 above conditions are false /sbin/anacron runs

Hope, this was helpful. Please enjoy

Read more...

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP