Help with a script that involves processes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with a script that involves processes
# 1  
Old 03-27-2018
Question Help with a script that involves processes

Hi everyone!

I need to create a bash script that allows me to copy in a file named report_<date>_<time>.csv the list of active processes.

<date> and <time> are the date and the time of the system when you create the file .csv

How can I create that? I have no idea how to do it Smilie

Thanks a lot
# 2  
Old 03-27-2018
Please provide sample-data with sensitive data stripped off(if necessary), show the desired output, explain the steps how you want the data to be created and show the steps you did yourself so far. Please use [CODE] ... [/CODE] - Tags to make your code easily readable for potential helpers.

Last edited by stomp; 03-27-2018 at 06:08 AM..
# 3  
Old 03-27-2018
I just need to create a file with the list of active processes until the file himself his killed. The choises are made from a menu in another bash file. I'm not sure how to do it beacuse I'm new in shell scripting.

The output in file csv will be, for example:

(name of file: report_20170318_123027.csv)

user1;19;ps;12:23:25;0:00:03
user2;53;firefox;13:00:13;0:03:40
user3;99;vim;13:22:53;1:00:25
user1;130;firefox;12:00:24;3:00:41
...


In the .csv file every line in composed by: user;pid;command;start;cputime but I know how to cut every information to compose every line. The only thing i need is to know how can i copy active processes in a file named like this.

The difficulty for me is to understand the commands i must use to:
- copy the list of active processes in a file
- name the file with date and time like i explain before
# 4  
Old 03-27-2018
Is this a homework assignment? Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost in the Homework & Coursework Questions forum.
# 5  
Old 03-27-2018
In particular: i have a menu with different choises. Every choise is a script.

The choise number 1 is: saving the list of active processes on the pc. The script periodically saves them (using sleep command) in a .csv file named report_<date>_<time>.csv.
<date> and <time> are the date and the time of the system when you create the file .csv

Every line of the .csv file reports an active process. For every process must be specify the following information, in this order:
{ USER; PID; COMMAND; START TIME; CPU TIME }
● COMMAND : name of the process without parameters
● START TIME : "HH:MM:SS"
● CPU TIME : [DD-]hh:mm:ss

---------- Post updated at 09:25 AM ---------- Previous update was at 09:23 AM ----------

It's not an homework for school, i'm tring to do a program to understand how processes commands works and also i/o redirection, but i have some difficulties Smilie
# 6  
Old 03-27-2018
Until you answer the questions raised in post #3 in this thread, you will not get any more help.

We take cheating on homework assignments very seriously!
This User Gave Thanks to Don Cragun For This Post:
# 7  
Old 03-27-2018
Quote:
Originally Posted by Novia96
... ... ...

It's not an homework for school, i'm tring to do a program to understand how processes commands works and also i/o redirection, but i have some difficulties Smilie
Then show us what you have tried and explain what you are unable to figure out.

If you show us what you have tried, we'll all have a much better understanding of where you are stuck and have a better chance of helping you expand on what you have already learned.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with shell script handling processes

Hello I have a file which has around 120 lines of commands. I am trying to write a shell script like which reads the 'command' file and executes line by line with some additional (common argument) with maximum 6 commands active at a time. Each of these commands when executed takes time... (5 Replies)
Discussion started by: JackyShane_36
5 Replies

2. Solaris

Script on Solaris spawning 2 processes for one shell script execution

Hi, I am having a shell script on Solaris 10 which has a while loop as shown below. #!/usr/bin/ksh # while do sleep 60 done Name of the shell script is coldcentric.sh. I executed script /DATAWAREHOUSE/LOAD/Scripts/coldcentric.sh from a command task in Informatica worklow as... (3 Replies)
Discussion started by: chekusi
3 Replies

3. Shell Programming and Scripting

Shell script executed from Informatica ETL tool is spawning 2 processes for one script

Hi, I am having a shell script which has a while loop as shown below. while do sleep 60 done I am executing this script from Informatica ETL tool command task from where we can execute UNIX commands/scripts. When i do that, i am seeing 2 processes getting started for one script... (2 Replies)
Discussion started by: chekusi
2 Replies

4. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (5 Replies)
Discussion started by: Ikebana
5 Replies

5. Shell Programming and Scripting

Need help with running processes script

I'm doing a script with the Shell. I need that it only show the number of running processes. Ex: echo "There are `command` running processes" Thnx! Pd: Sorry the idiom. I'm spanish. (2 Replies)
Discussion started by: Ikebana
2 Replies

6. Shell Programming and Scripting

script for failed processes

I want to write a script that log all the failed processes and start the same process. For that I have already write a script that gives all the PID #!/bin/ksh pid= `ps -ef |grep "ov" |grep -v "grep"| awk '{print $2}'` echo $pid if ; then echo "process is running" else echo... (4 Replies)
Discussion started by: kumarabhi84
4 Replies

7. Solaris

Identifying and grouping OS processes and APP processes

Hi Is there an easy way to identify and group currently running processes into OS processes and APP processes. Not all applications are installed as packages. Any free tools or scripts to do this? Many thanks. (2 Replies)
Discussion started by: wilsonee
2 Replies

8. UNIX for Advanced & Expert Users

Monitoring Processes - Killing hung processes

Is there a way to monitor certain processes and if they hang too long to kill them, but certain scripts which are expected to take a long time to let them go? Thank you Richard (4 Replies)
Discussion started by: ukndoit
4 Replies

9. Shell Programming and Scripting

Shell script creating too many processes.

I have a shell script that I am running every 60 seconds, but it is creating this process to the point that it is causing the server to perfrom poorly. Below is my script, what can I change to prevent this? while true do java -classpath .....( all my classes here) >/dev/null 2>&1 ... (3 Replies)
Discussion started by: Miller_K
3 Replies

10. Shell Programming and Scripting

Need a script to kill processes with PPID of 1

Hi, I have been trying to come up with a script to run as a cron job to kill any processes that have PPID of 1. I have created a file that contains the PID and the PPID. How can I read this file and then execute a kill on any PID where PPID is 1. The file looks like this: 4904 1 4455 1... (5 Replies)
Discussion started by: lbaysdon
5 Replies
Login or Register to Ask a Question