Questions tagged [shell-scripting]

Programming in an Interpreted language executed by a running Shell

Generic programming in an Interpreted language (as opposed to compiled) executed by a running Shell. Sometimes referred to as "Glue Code" due to the practice of managing the execution and output of one or more compiled binaries and passing said output to another series of commands.

621 questions
3
votes
1 answer

How can we limit and give space in after each special character in bash script output?

I have to send all rpm related information to our log analyzer and I am running the command below which give continuous output as follows: CMD sudo rpm -qa --info | egrep 'Name|Version|Architecture|Install Date|Vendor|Description' O/P Name …
Santosh Garole
  • 453
  • 1
  • 4
  • 11
2
votes
1 answer

compare between two times ubuntu shell script

I am working on a shell script which will do some things if the current time is between 19:00 and 1:00 am, so I get the current time in this way: currenttime=$(date +%H%M%S); and I convert the starttime and endtime format like this: …
ahmad blat
  • 21
  • 1
2
votes
1 answer

convert date time epoch in miliseconds to UTC human readable format

I am trying to convert date time in epoch to UTC human readable format, I have tried this and this gives me the result in CET but wrong result. perl -e 'print scalar localtime(1549950859468 / 1000) Tue Feb 12 06:54:19 2019 How should it be done in…
Alex
  • 172
  • 1
  • 1
  • 8
2
votes
1 answer

shell scripting running service status command and exit

I'm on Ubuntu 16.04. Running service nginx status puts me in a interactive mode with this process. I want to exit, which normally on a terminal is done by pressing q, but right now I'm writing this as part of a shell script. Is there a way to exit…
TurtleTread
  • 123
  • 6
2
votes
1 answer

How to start a jar file using systemd

I want to start java application on system boot using systemd. I tried to do by adding above scripts. But service is not starting.…
Janith
  • 223
  • 2
  • 4
  • 8
2
votes
1 answer

powershell script get-ADGroup and get-ADGroupmember

I have a problem trying to "fix" a PS script I got from a collegue to get me information from a customers AD. I'm trying to get a list of all distrobution mailboxes and members of these. But the script he gave me doesn't work, I've tried to change…
Hege Jacobsen
  • 79
  • 2
  • 3
  • 9
2
votes
2 answers

`wget`-ting a website for "local" browsing on a different domain

I need to mirror a website and deploy the copy under a different domain name. The mirroring procedure should be all automatic, so that I can update the copy on a regular basis with cron. The mirror MUST NOT be a real mirror, but it MUST be static…
Lucio Crusca
  • 420
  • 3
  • 12
  • 33
2
votes
1 answer

What modifies PAM files upon rpm installation to add configuration changes?

This question is meant for general application, but I can use some specific examples to illustrate the nature of my question. When certain Linux authentication packages like krb5, sssd, or pam_pkcs11 are installed something goes into the files under…
SeligkeitIstInGott
  • 179
  • 2
  • 5
  • 19
2
votes
1 answer

Tee command is reducing the lines?

I have the code like this : 54 08 * * * /usr/local/bin/curator --dry-run --config /home/itadmin/.curator/curator.yml /home/itadmin/.curator/daily.yml 2>&1 | /usr/bin/tee -a /home/itadmin/.curator/logs.txt | /usr/bin/tee…
Private
  • 277
  • 1
  • 2
  • 9
2
votes
2 answers

shell script to delete 6 month old logs from log file

I have log file of size 6.2 GB which is in use by the process and it keeps writing logs into this file. Now I don't want to rotate logs however i do want to clean this log file. I want to delete logs which are older than 6 months from this file. Is…
Shailesh Sutar
  • 1,517
  • 5
  • 23
  • 41
2
votes
1 answer

powershell: how to print command to file?

I'm currently using the Out-File cmdlet, like so: PS> Some-Cmdlet -someswitch | Out-File -filepath .\somefile.txt It works great. Is there anyway that I can actually get the command line itself to print to the same file before the output? In other…
Daniel
  • 1,614
  • 9
  • 29
  • 47
2
votes
3 answers

How to compress this mysqldump?

i have this script and it works but the output isn't zipped so it's huge. I want to save it zipped but i don't understand shell script and i don't want to mess it up. Can you help me zip it like so: ".sql.zip", please? /usr/bin/mysqldump -h…
Michael Rogers
  • 60
  • 1
  • 3
  • 16
2
votes
3 answers

Make find succeed even if there are no matching files

I'm using find in a bash script to clean up some cached files more than a day old: find /tmp/my_files_*.cache -mtime +1 -delete The problem is if the command matches no files it fails which prevents the rest of the script from running: find:…
Tamlyn
  • 123
  • 3
2
votes
2 answers

How do I include the password for the user 'postgres' in a maintenance script?

I'm setting up a cron job to do some routine maintenance for a postgresql database. The script is as follows: #!/bin/sh dbname="dbname" username="postgres" psql -d $dbname -U $username << EOF delete from links_link where submitted_on > now() -…
Hassan Baig
  • 2,325
  • 12
  • 29
  • 48
2
votes
1 answer

How to kill a disowned while loop?

So I've done something like this: $ while true; do ssh sysremote -CN; done & disown % In the ps -ef only ssh sysremote -CN is listed. How do I kill the while loop?
naisanza
  • 170
  • 4