Submitting a Batch Job in PBS

本文介绍了如何在Dell Linux集群上使用PBS批处理作业管理系统提交串行和并行作业。通过示例展示了如何编写批处理脚本来指定作业需求,包括资源分配、运行时间及输出文件等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The current batch job manager on Dell Linux clusters is PBS. To send a batch job to PBS, users need to write a script that is readable by PBS to specify their needs. A PBS script is bascially a shell script which contains embedded information for PBS. The PBS information takes the form of a special comment line which starts with #PBS and continues with PBS specific options.

Two example scripts, with comments, illustrates how this is done. To set the context, we'll assume the user name is myName, and the script file is named myJob.

A Serial Job Script (One Process)

To run a serial job with PBS, you might create a bash shell script named myJob with the following contents:

 #!/bin/bash
 #
 # All PBS instructions must come at the beginning of the script ,before
 # any executable commands occur. 
 #
 # Start by selecting the "single" queue, and providing an allocation code.
 #
 #PBS -q single
 #PBS -A your_allocation_code
 #
 # To run a serial job, a single node with one process is required.
 #
 #PBS -l nodes=1:ppn=1
 # 
 # We then indicate how long the job should be allowed to run in terms of
 # wall-clock time. The job will be killed if it tries to run longer than this.
 #
 #PBS -l walltime=00:10:00
 # 
 # Tell PBS the name of a file to write standard output to, and that standard
 # error should be merged into standard output.
 #
 #PBS -o /scratch/myName/serial/output
 #PBS -j oe
 #
 # Give the job a name so it can be found readily with qstat.
 #
 #PBS -N MySerialJob
 #
 # That is it for PBS instructions. The rest of the file is a shell script.
 # 
 # PLEASE ADOPT THE EXECUTION SCHEME USED HERE IN YOUR OWN PBS SCRIPTS:
 #
 #   1. Copy the necessary files from your home directory to your scratch directory.
 #   2. Execute in your scratch directory.
 #   3. Copy any necessary files back to your home directory.

 # Let's mark the time things get started with a date-time stamp.

 date

 # Set some handy environment variables.

 export HOME_DIR=/home/myName/serial
 export WORK_DIR=/scratch/myName/serial
 
 # Make sure the WORK_DIR exists:

 mkdir -p $WORK_DIR

 # Copy files, jump to WORK_DIR, and execute a program called "demo"

 cp $HOME_DIR/demo $WORK_DIR
 cd $WORK_DIR
 ./demo

 # Mark the time it finishes.

 date

 # And we're out'a here!

 exit 0

Once the contents of myJob meets your requirements, it can be submitted with the qsub command as so:

qsub myJob

A Parallel Job Script (Multiple Processes)

To run a parallel job, you would follow much the same process as the previous example. This time the contents of your file myJobwould contain:

 #!/bin/bash
 #
 # Use "workq" as the job queue, and specify the allocation code.
 #
 #PBS -q workq
 #PBS -A your_allocation_code
 # 
 # Assuming you want to run 16 processes, and each node supports 4 processes, 
 # you need to ask for a total of 4 nodes. The number of processes per node 
 # will vary from machine to machine, so double-check that your have the right 
 # values before submitting the job.
 #
 #PBS -l nodes=4:ppn=4
 # 
 # Set the maximum wall-clock time. In this case, 10 minutes.
 #
 #PBS -l walltime=00:10:00
 # 
 # Specify the name of a file which will receive all standard output,
 # and merge standard error with standard output.
 #
 #PBS -o /scratch/myName/parallel/output
 #PBS -j oe
 # 
 # Give the job a name so it can be easily tracked with qstat.
 #
 #PBS -N MyParJob
 #
 # That is it for PBS instructions. The rest of the file is a shell script.
 # 
 # PLEASE ADOPT THE EXECUTION SCHEME USED HERE IN YOUR OWN PBS SCRIPTS:
 #
 #   1. Copy the necessary files from your home directory to your scratch directory.
 #   2. Execute in your scratch directory.
 #   3. Copy any necessary files back to your home directory.

 # Let's mark the time things get started.

 date

 # Set some handy environment variables.

 export HOME_DIR=/home/$USER/parallel
 export WORK_DIR=/scratch/myName/parallel
 
 # Set a variable that will be used to tell MPI how many processes will be run.
 # This makes sure MPI gets the same information provided to PBS above.

 export NPROCS=`wc -l $PBS_NODEFILE |gawk '//{print $1}'`

 # Copy the files, jump to WORK_DIR, and execute! The program is named "hydro".

 cp $HOME_DIR/hydro $WORK_DIR
 cd $WORK_DIR
 mpirun -machinefile $PBS_NODEFILE -np $NPROCS $WORK_DIR/hydro

 # Mark the time processing ends.

 date
 
 # And we're out'a here!

 exit 0

Once the file myJob contains all the information for the desired parallel process, it can be submitted it with qsub, just as before:

 qsub myJob

Shell Environment Variables

Users with more experience writing shell scripts can take advantage of additional shell environment variables which are set by PBS when the job begins to execute. Those interested are directed to the qsub man page for a list and descriptions.

https://docs.loni.org/wiki/Submitting_a_Batch_Job_in_PBS

<think>好的,用户想知道如何在提交表单前附加字体文件。首先,我需要确定用户的具体场景。通常,表单提交可能涉及网页表单或者电子邮件表单,但根据常见情况,用户可能是在网页开发中需要上传字体文件。 接下来,考虑如何将字体文件附加到表单数据中。网页表单通常使用HTML和JavaScript,所以可能需要用FormData对象来收集文件数据。用户可能需要在前端通过<input type="file">选择文件,然后使用JavaScript将其添加到表单数据中,再通过AJAX提交。这时候要确保后端能够处理文件上传,比如使用Node.js的Express框架或者PHP的$_FILES。 另外,用户可能遇到字体文件无法上传的问题,需要检查文件类型是否被允许,比如.woff、.ttf等,以及服务器配置是否正确。同时,安全性方面,需要验证文件类型和大小,防止恶意文件上传。 还要考虑引用中的内容。引用[2]提到提交后需要保留证据,比如截图或邮件确认。所以在用户提交后,提示他们保存确认信息是必要的。引用[3]提到预印本的分享,虽然和字体文件无关,但可能用户担心版权问题,需要确保字体文件的使用符合许可协议。 最后,生成相关问题时要覆盖表单提交的其他方面,如文件类型限制、安全性、验证方法以及后端处理,这样用户可以得到全面的信息。</think>在提交表单前附加字体文件,通常需要根据表单的类型(网页表单、电子邮件附件等)采用不同的方法。以下是分步骤说明: ### 一、网页表单附加字体文件的方法 1. **前端文件上传控件** 在HTML表单中添加文件上传字段: ```html <form id="myForm" enctype="multipart/form-data"> <input type="file" name="fontFile" accept=".ttf, .otf, .woff, .woff2"> </form> ``` - `enctype="multipart/form-data"` 确保支持文件传输 - `accept` 属性限制可上传的文件类型 2. **JavaScript动态附加文件** 若需通过脚本动态添加文件: ```javascript const fileInput = document.querySelector('input[type="file"]'); const fontFile = new File([blobData], 'custom_font.woff2', {type: 'font/woff2'}); // 创建DataTransfer对象并附加文件 const dataTransfer = new DataTransfer(); dataTransfer.items.add(fontFile); fileInput.files = dataTransfer.files; ``` 3. **后端接收验证** 以Node.js Express为例: ```javascript app.post('/submit-form', (req, res) => { const fontFile = req.files.fontFile; if (!fontFile.mimetype.includes('font')) { return res.status(400).send('仅允许字体文件'); } // 保存文件到服务器 fontFile.mv(`/uploads/${fontFile.name}`); }); ``` ### 二、注意事项 1. **文件类型限制** 常见字体文件扩展名:`.ttf`(TrueType)、`.otf`(OpenType)、`.woff`/`.woff2`(Web开放字体) 2. **安全性验证** - 检查MIME类型(如`application/font-woff`) - 限制文件大小(如Apache配置`LimitRequestBody`) - 使用病毒扫描工具检查上传文件 3. **浏览器兼容性** 使用`File API`时需注意旧版浏览器支持问题,可通过`feature detection`处理: ```javascript if (window.File && window.FileReader) { // 支持现代文件操作 } ``` ### 三、引用说明 提交后需保留上传凭证(如服务器返回的`transaction ID`),若遇到问题可提供浏览器控制台日志或网络请求截图作为证据[^2]。若涉及字体版权,需确保符合许可证要求(如OFL许可证)[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值