web-dev-qa-db-fra.com

Comment puis-je empêcher la sortie de ps -ef?

Je dois vérifier le nombre de scripts actuellement exécutés sous Linux en fonction desquels je dois décider de réexécuter le script ou non. Le problème est que le classpath est trop long, donc lors de l'exécution de ps -ef. Je ne reçois pas le chemin complet, mais seulement partiellement.

Par exemple:

00:04:43 /usr/Java/jdk1.6/bin/Java -classpath /usr/share/groovy-2.0.5/lib/groovy-2.0.5.jar -Dscript.name=/usr/share/groovy-2.0.5/bin/groovy -Dprogram.name=groovy -Dgroovy.starter.conf=/usr/share/groovy-2.0.5/conf/groovy-starter.conf -Dgroovy.home=/usr/share/groovy-2.0.5 -Dtools.jar=/usr/Java/jdk1.6/lib/tools.jar org.codehaus.groovy.tools.GroovyStarter --main groovy.ui.GroovyMain --conf /usr/share/groovy-2.0.5/conf/groovy-starter.conf --classpath /usr/share/groovy-2.0.5/lib_novabill/mail.jar:/app/kenanfx/site_specific/apits/javaclient/Java:/app/kenanfx/bsdm_site/config:/app/kenanfx/FXSecServer-6.0.20120520/server/config:/app/kenanfx/site_specific/apits/javaclient/Java/aimw.jar:/app/kenanfx/site_specific/apits/javaclient/Java/aimwDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/aruba.jar:/app/kenanfx/site_specific/apits/javaclient/Java/arubaDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/bali.jar:/app/kenanfx/site_specific/apits/javaclient/Java/bali_2tier.jar:/app/kenanfx/site_specific/apits/javaclient/Java/baliDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/batch.jar:/app/kenanfx/site_specific/apits/javaclient/Java/batchDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/cit.jar:/app/kenanfx/site_specific/apits/javaclient/Java/citDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/commons-httpclient-2.0-alpha3.jar:/app/kenanfx/site_specific/apits/javaclient/Java/commons-logging-1.0.3.jar:/app/kenanfx/site_specific/apits/javaclient/Java/configurator.jar:/app/kenanfx/site_specific/apits/javaclient/Java/configuratorDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/ContentCatalog.jar:/app/kenanfx/site_specific/apits/javaclient/Java/ContentCatalogDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/customerudt.jar:/app/kenanfx/site_specific/apits/javaclient/Java/customerudtDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/ducm.jar:/app/kenanfx/site_specific/apits/javaclient/Java/ducmDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/FXSecBPRules.jar:/app/kenanfx/site_specific/apits/javaclient/Java/FXSecFwkClient.jar:/app/kenanfx/site_specific/apits/javaclient/Java/FXSecFwkDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/inventory.jar:/app/kenanfx/site_specific/apits/javaclient/Java/inventoryDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/javaee-api-5.0-2.jar:/app/kenanfx/site_specific/apits/javaclient/Java/jaxb-api.jar:/app/kenanfx/site_specific/apits/javaclient/Java/jaxb-impl.jar:/app/kenanfx/site_specific/apits/javaclient/Java/jaxb-libs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/jax-qname.jar:/app/kenanfx/site_specific/apits/javaclient/Java/JNITuxedo.jar:/app/kenanfx/site_specific/apits/javaclient/Java/JNITuxedo_2tier.jar:/app/kenanfx/site_specific/apits/javaclient/Java/namespace.jar:/app/kenanfx/site_specific/apits/javaclient/Java/ordering.jar:/app/kenanfx/site_specific/apits/javaclient/Java/orderingDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/PayPerView.jar:/app/kenanfx/site_specific/apits/javaclient/Java/PayPerViewDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/relaxngDatatype.jar:/app/kenanfx/site_specific/apits/javaclient/Java/serviceability.jar:/app/kenanfx/site_specific/apits/javaclient/Java/serviceabilityDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/sfq.jar:/app/kenanfx/site_specific/apits/javaclient/Java/sfqDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/shieldware.jar:/app/kenanfx/site_specific/apits/javaclient/Java/tuxedo.jar:/app/kenanfx/site_specific/apits/javaclient/Java/udt.jar:/app/kenanfx/site_specific/apits/javaclient/Java/udtDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/utility.jar:/app/kenanfx/site_specific/apits/javaclient/Java/utilityDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/workflow.jar:/app/kenanfx/site_specific/apits/javaclient/Java/workflowDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/workpoint.jar:/app/kenanfx/site_specific/apits/javaclient/Java/workpointDocs.jar:/app/kenanfx/site_specific/apits/javaclient/Java/xsdlib.jar:/app/

Alors, comment récupérer les informations requises?

2
AMAN KUMAR

Comment obtenir les lignes complètes dans la sortie

Pour obtenir la sortie complète, vous pouvez ajouter ww après la commande:

ps -ef ww

Ensuite, les lignes de la sortie ne seront pas coupées.
J'utilise souvent cela dans les scripts pour m'assurer que la sortie correspond pleinement au script en cours d'exécution.

Exemple:

de ps -ef:

jacob    11173  5876  0 apr19 ?        00:00:08 /usr/bin/unity-scope-

tandis que ps -ef ww sais:

jacob    11173  5876  0 apr19 ?        Sl     0:08 /usr/bin/unity-scope-loader applications/applications.scope applications/scopes.scope commands.scope
3
Jacob Vlijm

Utilisez pgrep. Par exemple, pgrep Java -a.

Un test avec Google Chrome traite:

$ pgrep chrome -a 
3572 /opt/google/chrome/chrome       
3584 /opt/google/chrome/chrome-sandbox /opt/google/chrome/chrome --type=zygote
3586 /opt/google/chrome/chrome --type=zygote
3588 /opt/google/chrome/chrome-sandbox /opt/google/chrome/nacl_helper
3592 /opt/google/chrome/chrome --type=zygote
3689 /opt/google/chrome/chrome --type=gpu-process --channel=3572.0.1702347006 --window-depth=24 --supports-dual-gpus=false --gpu-driver-bug-workarounds=4,25,33,36,48,53,64,66 --disable-accelerated-video-decode --gpu-vendor-id=0x10de --gpu-device-id=0x11a1 --gpu-driver-vendor=NVIDIA --gpu-driver-version=364.16 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
3739 /opt/google/chrome/chrome --type=gpu-broker                                                                                                                                                                                                                                                                                                                
3759 /opt/google/chrome/chrome --type=renderer --enable-features=LinuxObsoleteSystemIsEndOfTheLine<LinuxObsoleteSystemIsEndOfTheLine,WebFontsIntervention<WebFontsIntervention --lang=en-GB --force-fieldtrials=AppBannerTriggering/Aggressive/AutofillProfileOrderByFrecency/Enabled/BrotliEncoding/Default/CaptivePortalInterstitial/Enabled/*ChildAccountDetection/Disabled/*ClientSideDetectionModel/Model0/*CrossDevicePromo/28DaySingleProfile/*DataReductionProxyConfigService/Enabled/*ExtensionActionRedesign/Enabled/*ExtensionDeveloperModeWarning/Default/*GFE/Default/InstanceID/Enabled/LinuxObsoleteSystemIsEndOfTheLine/EndOfLine/MaterialDesignDownloads/Enabled/*OmniboxBundledExperimentV1/Unused_2/PasswordBranding/Disabled/*PasswordGeneration/Disabled/*QUIC/EnabledNoId/ReportCertificateErrors/ShowAndPossiblySend/*ResourcePriorities/Launch50pct_11011_1_1_10/SHA1IdentityUIWarning/Enabled/SHA1ToolbarUIJanuary2016/Warning/SHA1ToolbarUIJanuary2017/Error/SSLCommonNameMismatchHandling/Disabled/*SafeBrowsingIncidentReportingService/Default/SafeBrowsingIncidentReportingServiceFeatures/Default/SafeBrowsingUnverifiedDownloads/DisableByParameterMostSbTypes2/SafeBrowsingUpdateFrequency/Default/*UMA-Population-Restrict/normal/*UMA-Uniformity-Trial-1-Percent/group_32/*UMA-Uniformity-Trial-10-Percent/group_08/*UMA-Uniformity-Trial-100-Percent/group_01/*UMA-Uniformity-Trial-20-Percent/group_04/*UMA-Uniformity-Trial-5-Percent/group_13/*UMA-Uniformity-Trial-50-Percent/group_01/*UseDelayAgnosticAEC/DefaultEnabled/WebFontsIntervention/Enabled/WebRTC-LocalIPPermissionCheck/Enabled/WebRTC-PeerConnectionDTLS1.2/Enabled/ --extension-process --enable-webrtc-hw-h264-encoding --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --blink-settings=fetchDeferLateScripts=true,fetchIncreaseFontPriority=true,fetchIncreasePriorities=true --enable-suggestions-with-substring-match --enable-pinch --num-raster-threads=4 --content-image-texture-target
3890 /opt/google/chrome/chrome --type=renderer --enable-features=LinuxObsoleteSystemIsEndOfTheLine<LinuxObsoleteSystemIsEndOfTheLine,WebFontsIntervention<WebFontsIntervention --lang=en-GB --force-fieldtrials=AppBannerTriggering/Aggressive/AutofillProfileOrderByFrecency/Enabled/BrotliEncoding/Default/CaptivePortalInterstitial/Enabled/*ChildAccountDetection/Disabled/*ClientSideDetectionModel/Model0/*CrossDevicePromo/28DaySingleProfile/*DataReductionProxyConfigService/Enabled/*ExtensionActionRedesign/Enabled/*ExtensionDeveloperModeWarning/Default/*GFE/Default/InstanceID/Enabled/LinuxObsoleteSystemIsEndOfTheLine/EndOfLine/MaterialDesignDownloads/Enabled/*OmniboxBundledExperimentV1/Unused_2/PasswordBranding/Disabled/*PasswordGeneration/Disabled/*QUIC/EnabledNoId/ReportCertificateErrors/ShowAndPossiblySend/*ResourcePriorities/Launch50pct_11011_1_1_10/SHA1IdentityUIWarning/Enabled/SHA1ToolbarUIJanuary2016/Warning/SHA1ToolbarUIJanuary2017/Error/SSLCommonNameMismatchHandling/Disabled/*SafeBrowsingIncidentReportingService/Default/SafeBrowsingIncidentReportingServiceFeatures/Default/SafeBrowsingUnverifiedDownloads/DisableByParameterMostSbTypes2/SafeBrowsingUpdateFrequency/Default/*UMA-Population-Restrict/normal/*UMA-Uniformity-Trial-1-Percent/group_32/*UMA-Uniformity-Trial-10-Percent/group_08/*UMA-Uniformity-Trial-100-Percent/group_01/*UMA-Uniformity-Trial-20-Percent/group_04/*UMA-Uniformity-Trial-5-Percent/group_13/*UMA-Uniformity-Trial-50-Percent/group_01/*UseDelayAgnosticAEC/DefaultEnabled/*WebFontsIntervention/Enabled/WebRTC-LocalIPPermissionCheck/Enabled/WebRTC-PeerConnectionDTLS1.2/Enabled/ --extension-process --enable-webrtc-hw-h264-encoding --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --blink-settings=fetchDeferLateScripts=true,fetchIncreaseFontPriority=true,fetchIncreasePriorities=true --enable-suggestions-with-substring-match --enable-pinch --num-raster-threads=4 --content-image-texture-targe

Vu la longueur des deux dernières lignes, je ne pense pas que cela posera de problème.

1
muru